2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
2015-07-16 23:54:20 +08:00
|
|
|
NylasStore = require 'nylas-store'
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-07-16 23:54:20 +08:00
|
|
|
{Thread,
|
|
|
|
Message,
|
|
|
|
Actions,
|
|
|
|
DatabaseStore,
|
2015-04-01 08:19:17 +08:00
|
|
|
WorkspaceStore,
|
2015-04-09 10:25:00 +08:00
|
|
|
FocusedContentStore,
|
feat(work): Create the "Work" window, move TaskQueue, Nylas sync workers
Summary:
Move sync workers and Edgehill token checks to work window
Move the task queue and database setup to the work window
Move ContactStore background refresh to work window
Store the task queue in the database
WIP
The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed
Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state
DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually.
If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window.
This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window
ActivitySidebar has a special little store that observes the task queue since it's no longer in the window
Move "toggle component regions" / "toggle react remote" to the Developer menu
Move sync worker specs, update draft store specs to not rely on TaskQueue at all
Test Plan: Run existing tests, all pass
Reviewers: dillon, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D1936
2015-08-28 07:39:40 +08:00
|
|
|
TaskQueueStatusStore,
|
2016-01-09 06:58:31 +08:00
|
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
2016-01-26 08:36:56 +08:00
|
|
|
{ListTabular} = require 'nylas-component-kit'
|
2015-07-16 23:54:20 +08:00
|
|
|
|
2016-01-16 06:26:07 +08:00
|
|
|
ThreadListDataSource = require './thread-list-data-source'
|
2016-01-09 06:31:33 +08:00
|
|
|
|
2015-07-16 23:54:20 +08:00
|
|
|
class ThreadListStore extends NylasStore
|
|
|
|
constructor: ->
|
2016-01-13 01:49:49 +08:00
|
|
|
@listenTo FocusedPerspectiveStore, @_onPerspectiveChanged
|
2016-01-15 07:04:17 +08:00
|
|
|
@createListDataSource()
|
2015-05-22 09:08:29 +08:00
|
|
|
|
2016-01-16 06:26:07 +08:00
|
|
|
dataSource: =>
|
2016-01-15 07:04:17 +08:00
|
|
|
@_dataSource
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2016-01-16 06:26:07 +08:00
|
|
|
createListDataSource: =>
|
|
|
|
@_dataSourceUnlisten?()
|
2016-01-26 08:36:56 +08:00
|
|
|
@_dataSource = null
|
|
|
|
|
|
|
|
threadsSubscription = FocusedPerspectiveStore.current().threads()
|
|
|
|
if threadsSubscription
|
|
|
|
@_dataSource = new ThreadListDataSource(threadsSubscription)
|
|
|
|
@_dataSourceUnlisten = @_dataSource.listen(@_onDataChanged, @)
|
|
|
|
|
|
|
|
# Set up a one-time listener to focus an item in the new view
|
|
|
|
if WorkspaceStore.layoutMode() is 'split'
|
|
|
|
unlisten = @_dataSource.listen =>
|
|
|
|
if @_dataSource.loaded()
|
|
|
|
Actions.setFocus(collection: 'thread', item: @_dataSource.get(0))
|
|
|
|
unlisten()
|
|
|
|
else
|
|
|
|
@_dataSource = new ListTabular.DataSource.Empty()
|
2015-11-19 04:28:54 +08:00
|
|
|
|
2015-04-07 02:46:20 +08:00
|
|
|
@trigger(@)
|
2016-01-15 07:04:17 +08:00
|
|
|
Actions.setFocus(collection: 'thread', item: null)
|
feat(selection): add selection of read, unread, starred, etc
Summary:
Can select all, deselect-all, read, unread, starred, unstarred.
Yes, it's not REALLY select "all", but it uses the items in the current
`retainedRange`. This is actually similar to what gmail does (only selects
on the first page of a 100).
Test Plan: new test
Reviewers: juan, bengotow
Reviewed By: bengotow
Differential Revision: https://phab.nylas.com/D2241
2015-11-09 23:03:55 +08:00
|
|
|
|
2015-04-01 08:19:17 +08:00
|
|
|
# Inbound Events
|
|
|
|
|
2016-01-16 06:26:07 +08:00
|
|
|
_onPerspectiveChanged: =>
|
2016-01-15 07:04:17 +08:00
|
|
|
@createListDataSource()
|
2015-06-27 07:15:21 +08:00
|
|
|
|
2016-01-15 07:04:17 +08:00
|
|
|
_onDataChanged: ({previous, next} = {}) =>
|
2016-01-09 06:31:33 +08:00
|
|
|
if previous and next
|
2015-10-22 01:38:00 +08:00
|
|
|
focusedId = FocusedContentStore.focusedId('thread')
|
|
|
|
keyboardId = FocusedContentStore.keyboardCursorId('thread')
|
|
|
|
viewModeAutofocuses = WorkspaceStore.layoutMode() is 'split' or WorkspaceStore.topSheet().root is true
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2016-01-09 06:31:33 +08:00
|
|
|
focusedIndex = previous.offsetOfId(focusedId)
|
|
|
|
keyboardIndex = previous.offsetOfId(keyboardId)
|
2015-06-09 08:02:50 +08:00
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
shiftIndex = (i) =>
|
2016-01-09 06:31:33 +08:00
|
|
|
if i > 0 and (next.modelAtOffset(i - 1)?.unread or i >= next.count())
|
2015-10-22 01:38:00 +08:00
|
|
|
return i - 1
|
|
|
|
else
|
|
|
|
return i
|
2015-06-09 08:02:50 +08:00
|
|
|
|
2016-01-09 06:31:33 +08:00
|
|
|
focusedLost = focusedIndex >= 0 and next.offsetOfId(focusedId) is -1
|
|
|
|
keyboardLost = keyboardIndex >= 0 and next.offsetOfId(keyboardId) is -1
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
if viewModeAutofocuses and focusedLost
|
2016-01-09 06:31:33 +08:00
|
|
|
Actions.setFocus(collection: 'thread', item: next.modelAtOffset(shiftIndex(focusedIndex)))
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
if keyboardLost
|
2016-01-09 06:31:33 +08:00
|
|
|
Actions.setCursorPosition(collection: 'thread', item: next.modelAtOffset(shiftIndex(keyboardIndex)))
|
2015-07-22 05:16:11 +08:00
|
|
|
|
2016-01-09 06:31:33 +08:00
|
|
|
@trigger(@)
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-07-16 23:54:20 +08:00
|
|
|
module.exports = new ThreadListStore()
|