mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
9f998d1964
Summary: - WIP: Need to fix tests and some errors! - Refactors Category class to hold information about its type - Refactors CategoryStore to rely on observables instead of local caches - Adds and updates Observables and helpers - Refactors ContactStore to hold entire cache of contacts instead of per current account - Same for ContactRankingStore and other stores - Refactors method names for AccountStore + some helpers - Updates MailViewFilter to hold an account - Adds basic Unified filter - Replaces AccountStore.current calls with either: - The account of the currently focused MailViewFilter - The account associated with a thread, message, file, etc... - A parameter to be passed in - Arbitrarily, the first account in the AccountsStore Test Plan: - Unit tests Reviewers: evan, bengotow Differential Revision: https://phab.nylas.com/D2423
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.accounts()
|
|
|
|
_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
|