mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-21 22:54:11 +08:00
Summary: Originally, this was going to be a totally independent package, but I wasn't able to isolate the functionality and get it tied in to the delta-stream consumption. Here's how it currently works: - The preferences package has a new tab which allows you to edit mail filters. Filters are saved in a new core store, and a new stock component (ScenarioEditor) renders the editor. The editor takes a set of templates that define a value space, and outputs a valid set of values. - A new MailFilterProcessor takes messages and creates tasks to apply the actions from the MailFiltersStore. - The worker-sync package now uses the MailFilterProcessor to apply filters /before/ it calls didPassivelyReceiveNewModels, so filtrs are applied before any notifications are created. - A new task, ReprocessMailFiltersTask allows you to run filters on all of your existing mail. It leverages the existing TaskQueue architecture to: a) resume where it left off if you quit midway, b) be queryable (for status) from all windows and c) cancelable. The TaskQueue is a bit strange because it runs performLocal and performRemote very differently, and I had to use `performRemote`. (todo refactor soon.) This diff also changes the EditableList a bit to behave like a controlled component and render focused / unfocused states. Test Plan: Run tests, only for actual filter processing atm. Reviewers: juan, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2379
60 lines
1.6 KiB
CoffeeScript
60 lines
1.6 KiB
CoffeeScript
React = require 'react'
|
|
_ = require 'underscore'
|
|
{AccountStore, Actions} = require 'nylas-exports'
|
|
PreferencesAccountList = require './preferences-account-list'
|
|
PreferencesAccountDetails = require './preferences-account-details'
|
|
|
|
class PreferencesAccounts extends React.Component
|
|
@displayName: 'PreferencesAccounts'
|
|
|
|
constructor: (@props) ->
|
|
@state = @getStateFromStores()
|
|
@state.selected = @state.accounts[0]
|
|
|
|
componentDidMount: =>
|
|
@unsubscribe = AccountStore.listen @_onAccountsChanged
|
|
|
|
componentWillUnmount: =>
|
|
@unsubscribe?()
|
|
|
|
getStateFromStores: =>
|
|
accounts: AccountStore.items()
|
|
|
|
_onAccountsChanged: =>
|
|
@setState(@getStateFromStores())
|
|
|
|
|
|
# Update account list actions
|
|
#
|
|
_onAddAccount: =>
|
|
ipc = require('electron').ipcRenderer
|
|
ipc.send('command', 'application:add-account')
|
|
|
|
_onSelectAccount: (account) =>
|
|
@setState(selected: account)
|
|
|
|
_onRemoveAccount: (account) =>
|
|
Actions.removeAccount(account.id)
|
|
|
|
# Update account actions
|
|
#
|
|
_onAccountUpdated: (account, updates) =>
|
|
Actions.updateAccount(account.id, updates)
|
|
|
|
render: =>
|
|
<section className="preferences-accounts">
|
|
<h2>Accounts</h2>
|
|
<div className="accounts-content">
|
|
<PreferencesAccountList
|
|
accounts={@state.accounts}
|
|
selected={@state.selected}
|
|
onAddAccount={@_onAddAccount}
|
|
onSelectAccount={@_onSelectAccount}
|
|
onRemoveAccount={@_onRemoveAccount} />
|
|
<PreferencesAccountDetails
|
|
account={@state.selected}
|
|
onAccountUpdated={@_onAccountUpdated} />
|
|
</div>
|
|
</section>
|
|
|
|
module.exports = PreferencesAccounts
|