Skip to content

Commit b6a1fc5

Browse files
committed
[client-app] Fix measurement of thread-list action metrics
Summary: We detect when a thread is removed from the thread-list by listening to `Actions.threadListDidUpdate`. However, we were not firing the action at the correct moment. Before this commit, we fired the action on the root `ThreadList`'s `componentDidUpdate`, however did this not actually fire when the child list actually updated/removed threads from the list. This sort of used to work because before 396a027 the root ThreadList component re-rendered all the time, so it fired the action, but after initial sync, we would never actually report any thread-list action metrics at all Test Plan: manual Reviewers: spang, halla, evan Reviewed By: halla, evan Differential Revision: https://phab.nylas.com/D4051
1 parent fa17d2f commit b6a1fc5

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/client-app/internal_packages/thread-list/lib/thread-list.cjsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ class ThreadList extends React.Component
5757
(not Utils.isEqualReact(@state, nextState))
5858
)
5959

60-
componentDidUpdate: =>
61-
dataSource = ThreadListStore.dataSource()
62-
threads = dataSource.itemsCurrentlyInView()
63-
Actions.threadListDidUpdate(threads)
64-
6560
componentWillUnmount: =>
6661
@unsub()
6762
window.removeEventListener('resize', @_onResize, true)
@@ -137,10 +132,16 @@ class ThreadList extends React.Component
137132
onDoubleClick={(thread) -> Actions.popoutThread(thread)}
138133
onDragStart={@_onDragStart}
139134
onDragEnd={@_onDragEnd}
135+
onComponentDidUpdate={@_onThreadListDidUpdate}
140136
/>
141137
</FocusContainer>
142138
</FluxContainer>
143139

140+
_onThreadListDidUpdate: =>
141+
dataSource = ThreadListStore.dataSource()
142+
threads = dataSource.itemsCurrentlyInView()
143+
Actions.threadListDidUpdate(threads)
144+
144145
_threadPropsProvider: (item) ->
145146
classes = classnames({
146147
'unread': item.unread

packages/client-app/src/components/list-tabular.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class ListTabular extends Component {
9797
onDoubleClick: PropTypes.func,
9898
onDragStart: PropTypes.func,
9999
onDragEnd: PropTypes.func,
100+
onComponentDidUpdate: PropTypes.func,
100101
};
101102

102103
static defaultProps = {
@@ -133,6 +134,9 @@ class ListTabular extends Component {
133134
}
134135

135136
componentDidUpdate(prevProps) {
137+
if (this.props.onComponentDidUpdate) {
138+
this.props.onComponentDidUpdate()
139+
}
136140
// If our view has been swapped out for an entirely different one,
137141
// reset our scroll position to the top.
138142
if (prevProps.dataSource !== this.props.dataSource) {

packages/client-app/src/components/multiselect-list.cjsx

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class MultiselectList extends React.Component
3434
columns: React.PropTypes.array.isRequired
3535
itemPropsProvider: React.PropTypes.func.isRequired
3636
keymapHandlers: React.PropTypes.object
37+
onComponentDidUpdate: React.PropTypes.func
3738

3839
constructor: (@props) ->
3940
@state = @_getStateFromStores()
@@ -48,6 +49,8 @@ class MultiselectList extends React.Component
4849
@setState(@_getStateFromStores(newProps))
4950

5051
componentDidUpdate: (prevProps, prevState) =>
52+
if @props.onComponentDidUpdate
53+
@props.onComponentDidUpdate()
5154
if prevProps.focusedId isnt @props.focusedId or
5255
prevProps.keyboardCursorId isnt @props.keyboardCursorId
5356

@@ -120,6 +123,7 @@ class MultiselectList extends React.Component
120123
dataSource={@props.dataSource}
121124
itemPropsProvider={@itemPropsProvider}
122125
onSelect={@_onClickItem}
126+
onComponentDidUpdate={@props.onComponentDidUpdate}
123127
{...otherProps} />
124128
</KeyCommandsRegion>
125129
else

0 commit comments

Comments
 (0)