2015-05-20 06:59:37 +08:00
|
|
|
React = require 'react'
|
2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
2015-05-20 06:59:37 +08:00
|
|
|
classNames = require 'classnames'
|
|
|
|
NotificationStore = require './notifications-store'
|
2015-09-25 02:03:11 +08:00
|
|
|
InitialSyncActivity = require './initial-sync-activity'
|
2015-05-20 06:59:37 +08:00
|
|
|
{Actions,
|
|
|
|
TaskQueue,
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
AccountStore,
|
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
|
|
|
NylasSyncStatusStore,
|
2015-09-25 02:03:11 +08:00
|
|
|
TaskQueueStatusStore} = require 'nylas-exports'
|
2015-09-19 07:15:15 +08:00
|
|
|
ActivitySidebarLongPollStore = require './activity-sidebar-long-poll-store'
|
|
|
|
{TimeoutTransitionGroup, RetinaImg} = require 'nylas-component-kit'
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
class ActivitySidebar extends React.Component
|
|
|
|
@displayName: 'ActivitySidebar'
|
|
|
|
|
|
|
|
@containerRequired: false
|
2015-06-03 10:04:21 +08:00
|
|
|
@containerStyles:
|
|
|
|
minWidth: 165
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
maxWidth: 400
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @_getStateFromStores()
|
|
|
|
|
|
|
|
componentDidMount: =>
|
|
|
|
@_unlisteners = []
|
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
|
|
|
@_unlisteners.push TaskQueueStatusStore.listen @_onDataChanged
|
2015-05-20 06:59:37 +08:00
|
|
|
@_unlisteners.push NotificationStore.listen @_onDataChanged
|
2015-09-25 02:03:11 +08:00
|
|
|
@_unlisteners.push NylasSyncStatusStore.listen @_onDataChanged
|
2015-09-19 07:15:15 +08:00
|
|
|
@_unlisteners.push ActivitySidebarLongPollStore.listen @_onDeltaReceived
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
componentWillUnmount: =>
|
|
|
|
unlisten() for unlisten in @_unlisteners
|
|
|
|
@_workerUnlisten() if @_workerUnlisten
|
|
|
|
|
|
|
|
render: =>
|
2015-09-25 02:03:11 +08:00
|
|
|
items = [@_renderNotificationActivityItems(), @_renderTaskActivityItems()]
|
|
|
|
|
|
|
|
if @state.isInitialSyncComplete
|
|
|
|
if @state.receivingDelta
|
|
|
|
items.push @_renderDeltaSyncActivityItem()
|
|
|
|
else
|
2015-09-30 15:35:45 +08:00
|
|
|
items.push <InitialSyncActivity key="initial-sync" />
|
2015-05-20 06:59:37 +08:00
|
|
|
|
2015-09-19 07:15:15 +08:00
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
names = classNames
|
|
|
|
"sidebar-activity": true
|
|
|
|
"sidebar-activity-error": error?
|
|
|
|
|
2015-09-15 02:04:24 +08:00
|
|
|
wrapperClass = "sidebar-activity-transition-wrapper "
|
|
|
|
|
|
|
|
if items.length is 0
|
|
|
|
wrapperClass += "sidebar-activity-empty"
|
|
|
|
else
|
|
|
|
inside = <TimeoutTransitionGroup
|
|
|
|
className={names}
|
|
|
|
leaveTimeout={625}
|
|
|
|
enterTimeout={125}
|
|
|
|
transitionName="activity-opacity">
|
|
|
|
{items}
|
|
|
|
</TimeoutTransitionGroup>
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
<TimeoutTransitionGroup
|
2015-09-15 02:04:24 +08:00
|
|
|
className={wrapperClass}
|
2015-05-20 06:59:37 +08:00
|
|
|
leaveTimeout={625}
|
|
|
|
enterTimeout={125}
|
2015-09-15 02:04:24 +08:00
|
|
|
transitionName="activity-opacity">
|
|
|
|
{inside}
|
2015-05-20 06:59:37 +08:00
|
|
|
</TimeoutTransitionGroup>
|
|
|
|
|
|
|
|
_renderTaskActivityItems: =>
|
|
|
|
summary = {}
|
|
|
|
|
|
|
|
@state.tasks.map (task) ->
|
|
|
|
label = task.label?()
|
|
|
|
return unless label
|
|
|
|
summary[label] ?= 0
|
2015-10-01 00:54:14 +08:00
|
|
|
summary[label] += task.numberOfImpactedItems()
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
_.pairs(summary).map ([label, count]) ->
|
|
|
|
<div className="item" key={label}>
|
|
|
|
<div className="inner">
|
|
|
|
{label} <span className="count">({count})</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-09-19 07:15:15 +08:00
|
|
|
_renderDeltaSyncActivityItem: =>
|
|
|
|
<div className="item" key="delta-sync-item">
|
2015-09-28 16:37:25 +08:00
|
|
|
<div style={padding: "9px 9px 0 12px", float: "left"}>
|
|
|
|
<RetinaImg name="sending-spinner.gif" width={18} mode={RetinaImg.Mode.ContentPreserve} />
|
2015-09-19 07:15:15 +08:00
|
|
|
</div>
|
|
|
|
<div className="inner">
|
2015-10-03 06:01:26 +08:00
|
|
|
Syncing your mailbox…
|
2015-09-19 07:15:15 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
_renderNotificationActivityItems: =>
|
|
|
|
@state.notifications.map (notification) ->
|
|
|
|
<div className="item" key={notification.id}>
|
|
|
|
<div className="inner">
|
|
|
|
{notification.message}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
_onDataChanged: =>
|
|
|
|
@setState(@_getStateFromStores())
|
|
|
|
|
|
|
|
_getStateFromStores: =>
|
|
|
|
notifications: NotificationStore.notifications()
|
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
|
|
|
tasks: TaskQueueStatusStore.queue()
|
2015-09-25 02:03:11 +08:00
|
|
|
isInitialSyncComplete: NylasSyncStatusStore.isComplete()
|
2015-05-20 06:59:37 +08:00
|
|
|
|
2015-09-23 05:05:26 +08:00
|
|
|
_onDeltaReceived: (countDeltas) =>
|
|
|
|
tooSmallForNotification = countDeltas <= 10
|
|
|
|
return if tooSmallForNotification
|
|
|
|
|
2015-09-19 07:15:15 +08:00
|
|
|
if @_timeoutId
|
|
|
|
clearTimeout @_timeoutId
|
|
|
|
|
|
|
|
@_timeoutId = setTimeout(( =>
|
|
|
|
delete @_timeoutId
|
|
|
|
@setState receivingDelta: false
|
2015-09-23 05:05:26 +08:00
|
|
|
), 30000)
|
2015-09-19 07:15:15 +08:00
|
|
|
|
|
|
|
@setState receivingDelta: true
|
|
|
|
|
2015-05-20 06:59:37 +08:00
|
|
|
|
|
|
|
module.exports = ActivitySidebar
|