diff --git a/internal_packages/message-list/lib/thread-archive-button.cjsx b/internal_packages/message-list/lib/thread-archive-button.cjsx index 87d4e1bd3..82c35b40b 100644 --- a/internal_packages/message-list/lib/thread-archive-button.cjsx +++ b/internal_packages/message-list/lib/thread-archive-button.cjsx @@ -26,7 +26,7 @@ class ThreadArchiveButton extends React.Component return unless DOMUtils.nodeIsVisible(e.currentTarget) task = TaskFactory.taskForArchiving threads: [@props.thread], - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) Actions.popSheet() e.stopPropagation() diff --git a/internal_packages/message-list/lib/thread-trash-button.cjsx b/internal_packages/message-list/lib/thread-trash-button.cjsx index 68733f712..07f4abc06 100644 --- a/internal_packages/message-list/lib/thread-trash-button.cjsx +++ b/internal_packages/message-list/lib/thread-trash-button.cjsx @@ -28,7 +28,7 @@ class ThreadTrashButton extends React.Component return unless DOMUtils.nodeIsVisible(e.currentTarget) task = TaskFactory.taskForMovingToTrash threads: [@props.thread], - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) Actions.popSheet() e.stopPropagation() diff --git a/internal_packages/thread-list/lib/draft-list.cjsx b/internal_packages/thread-list/lib/draft-list.cjsx index 21a13d561..3ca1af021 100644 --- a/internal_packages/thread-list/lib/draft-list.cjsx +++ b/internal_packages/thread-list/lib/draft-list.cjsx @@ -76,7 +76,7 @@ class DraftList extends React.Component # Additional Commands _onRemoveFromView: => - items = DraftListStore.view().selection.items() + items = DraftListStore.dataSource().selection.items() for item in items Actions.destroyDraft(item.clientId) diff --git a/internal_packages/thread-list/lib/thread-buttons.cjsx b/internal_packages/thread-list/lib/thread-buttons.cjsx index 6176cdb5d..8532e7dfc 100644 --- a/internal_packages/thread-list/lib/thread-buttons.cjsx +++ b/internal_packages/thread-list/lib/thread-buttons.cjsx @@ -30,7 +30,7 @@ class ThreadBulkArchiveButton extends React.Component _onArchive: => task = TaskFactory.taskForArchiving threads: @props.selection.items(), - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) class ThreadBulkTrashButton extends React.Component @@ -54,7 +54,7 @@ class ThreadBulkTrashButton extends React.Component _onRemove: => task = TaskFactory.taskForMovingToTrash threads: @props.selection.items(), - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) @@ -115,13 +115,13 @@ ThreadNavButtonMixin = isFirstThread: -> selectedId = FocusedContentStore.focusedId('thread') - ThreadListStore.view().get(0)?.id is selectedId + ThreadListStore.dataSource().get(0)?.id is selectedId isLastThread: -> selectedId = FocusedContentStore.focusedId('thread') - lastIndex = ThreadListStore.view().count() - 1 - ThreadListStore.view().get(lastIndex)?.id is selectedId + lastIndex = ThreadListStore.dataSource().count() - 1 + ThreadListStore.dataSource().get(lastIndex)?.id is selectedId componentWillUnmount: -> @_unsubscribe() diff --git a/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx b/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx index 9de566cec..f16b82004 100644 --- a/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx +++ b/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx @@ -27,7 +27,7 @@ class ThreadArchiveQuickAction extends React.Component _onArchive: (event) => task = TaskFactory.taskForArchiving threads: [@props.thread] - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) # Don't trigger the thread row click @@ -56,7 +56,7 @@ class ThreadTrashQuickAction extends React.Component _onRemove: (event) => task = TaskFactory.taskForMovingToTrash threads: [@props.thread] - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) # Don't trigger the thread row click diff --git a/internal_packages/thread-list/lib/thread-list-scroll-tooltip.cjsx b/internal_packages/thread-list/lib/thread-list-scroll-tooltip.cjsx index b97df367f..59fca65ce 100644 --- a/internal_packages/thread-list/lib/thread-list-scroll-tooltip.cjsx +++ b/internal_packages/thread-list/lib/thread-list-scroll-tooltip.cjsx @@ -19,10 +19,10 @@ class ThreadListScrollTooltip extends React.Component @state?.idx isnt newState.idx setupForProps: (props) -> - idx = Math.floor(ThreadListStore.view().count() / @props.totalHeight * @props.viewportCenter) + idx = Math.floor(ThreadListStore.dataSource().count() / @props.totalHeight * @props.viewportCenter) @setState idx: idx - item: ThreadListStore.view().get(idx) + item: ThreadListStore.dataSource().get(idx) render: -> if @state.item diff --git a/internal_packages/thread-list/lib/thread-list-store.coffee b/internal_packages/thread-list/lib/thread-list-store.coffee index 7ed996f32..1cbf97f17 100644 --- a/internal_packages/thread-list/lib/thread-list-store.coffee +++ b/internal_packages/thread-list/lib/thread-list-store.coffee @@ -16,52 +16,36 @@ ThreadListViewFactory = require './thread-list-view-factory' # to annotate logical regions in the text. class ThreadListStore extends NylasStore constructor: -> - @_resetInstanceVars() - @listenTo FocusedPerspectiveStore, @_onPerspectiveChanged - @createView() + @createListDataSource() - # We can't create a @view on construction because the CategoryStore - # has hot yet been populated from the database with the list of - # categories and their corresponding ids. Once that is ready, the - # CategoryStore will trigger, which will update the - # FocusedPerspectiveStore, which will cause us to create a new - # @view. + dataSource: -> + @_dataSource - _resetInstanceVars: -> - @_lastQuery = null - - view: -> - @_view - - createView: -> + createListDataSource: -> mailboxPerspective = FocusedPerspectiveStore.current() return unless mailboxPerspective - @setView(ThreadListViewFactory.viewForPerspective(mailboxPerspective)) - Actions.setFocus(collection: 'thread', item: null) - - setView: (view) -> - @_viewUnlisten() if @_viewUnlisten - @_view = view - @_viewUnlisten = view.listen(@_onViewDataChanged, @) + @_dataSourceUnlisten() if @_dataSourceUnlisten + @_dataSource = ThreadListViewFactory.viewForPerspective(mailboxPerspective) + @_dataSourceUnlisten = @_dataSource.listen(@_onDataChanged, @) # Set up a one-time listener to focus an item in the new view if WorkspaceStore.layoutMode() is 'split' - unlisten = view.listen -> - if view.loaded() - Actions.setFocus(collection: 'thread', item: view.get(0)) + unlisten = @_dataSource.listen => + if @_dataSource.loaded() + Actions.setFocus(collection: 'thread', item: @_dataSource.get(0)) unlisten() @trigger(@) - + Actions.setFocus(collection: 'thread', item: null) # Inbound Events _onPerspectiveChanged: -> - @createView() + @createListDataSource() - _onViewDataChanged: ({previous, next} = {}) => + _onDataChanged: ({previous, next} = {}) => if previous and next focusedId = FocusedContentStore.focusedId('thread') keyboardId = FocusedContentStore.keyboardCursorId('thread') diff --git a/internal_packages/thread-list/lib/thread-list.cjsx b/internal_packages/thread-list/lib/thread-list.cjsx index 4088d3ae6..f2b05f319 100644 --- a/internal_packages/thread-list/lib/thread-list.cjsx +++ b/internal_packages/thread-list/lib/thread-list.cjsx @@ -43,10 +43,10 @@ class ThreadList extends React.Component window.removeEventListener('resize', @_onResize, true) _shift: ({offset, afterRunning}) => - view = ThreadListStore.view() + dataSource = ThreadListStore.dataSource() focusedId = FocusedContentStore.focusedId('thread') - focusedIdx = Math.min(view.count() - 1, Math.max(0, view.indexOfId(focusedId) + offset)) - item = view.get(focusedIdx) + focusedIdx = Math.min(dataSource.count() - 1, Math.max(0, dataSource.indexOfId(focusedId) + offset)) + item = dataSource.get(focusedIdx) afterRunning() Actions.setFocus(collection: 'thread', item: item) @@ -116,8 +116,8 @@ class ThreadList extends React.Component event.preventDefault() return - if itemThreadId in ThreadListStore.view().selection.ids() - dragThreadIds = ThreadListStore.view().selection.ids() + if itemThreadId in ThreadListStore.dataSource().selection.ids() + dragThreadIds = ThreadListStore.dataSource().selection.ids() else dragThreadIds = [itemThreadId] @@ -138,12 +138,12 @@ class ThreadList extends React.Component @setState(style: desired) _threadsForKeyboardAction: -> - return null unless ThreadListStore.view() + return null unless ThreadListStore.dataSource() focused = FocusedContentStore.focused('thread') if focused return [focused] - else if ThreadListStore.view().selection.count() > 0 - return ThreadListStore.view().selection.items() + else if ThreadListStore.dataSource().selection.count() > 0 + return ThreadListStore.dataSource().selection.items() else return null @@ -209,7 +209,7 @@ class ThreadList extends React.Component task = removeMethod threads: threads - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) Actions.popSheet() @@ -220,7 +220,7 @@ class ThreadList extends React.Component if threads task = TaskFactory.taskForArchiving threads: threads - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) Actions.popSheet() @@ -230,28 +230,28 @@ class ThreadList extends React.Component if threads task = TaskFactory.taskForMovingToTrash threads: threads - fromView: FocusedPerspectiveStore.current() + fromPerspective: FocusedPerspectiveStore.current() Actions.queueTask(task) Actions.popSheet() _onSelectRead: => - view = ThreadListStore.view() - items = view.itemsCurrentlyInViewMatching (item) -> not item.unread - view.selection.set(items) + dataSource = ThreadListStore.dataSource() + items = dataSource.itemsCurrentlyInViewMatching (item) -> not item.unread + dataSource.selection.set(items) _onSelectUnread: => - view = ThreadListStore.view() - items = view.itemsCurrentlyInViewMatching (item) -> item.unread - view.selection.set(items) + dataSource = ThreadListStore.dataSource() + items = dataSource.itemsCurrentlyInViewMatching (item) -> item.unread + dataSource.selection.set(items) _onSelectStarred: => - view = ThreadListStore.view() - items = view.itemsCurrentlyInViewMatching (item) -> item.starred - view.selection.set(items) + dataSource = ThreadListStore.dataSource() + items = dataSource.itemsCurrentlyInViewMatching (item) -> item.starred + dataSource.selection.set(items) _onSelectUnstarred: => - view = ThreadListStore.view() - items = view.itemsCurrentlyInViewMatching (item) -> not item.starred - view.selection.set(items) + dataSource = ThreadListStore.dataSource() + items = dataSource.itemsCurrentlyInViewMatching (item) -> not item.starred + dataSource.selection.set(items) module.exports = ThreadList diff --git a/src/components/multiselect-action-bar.cjsx b/src/components/multiselect-action-bar.cjsx index e855ba80b..00097aba3 100644 --- a/src/components/multiselect-action-bar.cjsx +++ b/src/components/multiselect-action-bar.cjsx @@ -108,9 +108,9 @@ class MultiselectActionBar extends React.Component _renderActions: => - return
unless @state.view + return unless @state.dataSource