Mailspring/internal_packages/preferences/lib/main.cjsx
Ben Gotow af67597f0b feat(mail-rules): Per-account mail rules filter incoming, existing mail
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
2015-12-23 02:19:32 -05:00

59 lines
1.6 KiB
CoffeeScript

{PreferencesUIStore,
Actions,
WorkspaceStore,
ComponentRegistry} = require 'nylas-exports'
{ipcRenderer} = require 'electron'
module.exports =
activate: ->
React = require 'react'
Cfg = PreferencesUIStore.TabItem
PreferencesUIStore.registerPreferencesTab(new Cfg {
tabId: 'General'
displayName: 'General'
component: require './tabs/preferences-general'
order: 1
})
PreferencesUIStore.registerPreferencesTab(new Cfg {
tabId: 'Accounts'
displayName: 'Accounts'
component: require './tabs/preferences-accounts'
order: 2
})
PreferencesUIStore.registerPreferencesTab(new Cfg {
tabId: 'Shortcuts'
displayName: 'Shortcuts'
component: require './tabs/preferences-keymaps'
order: 3
})
PreferencesUIStore.registerPreferencesTab(new Cfg {
tabId: 'Mail Rules'
displayName: 'Mail Rules'
component: require './tabs/preferences-mail-rules'
componentRequiresAccount: true
order: 4
})
WorkspaceStore.defineSheet 'Preferences', {},
split: ['Preferences']
list: ['Preferences']
PreferencesRoot = require('./preferences-root')
ComponentRegistry.register PreferencesRoot,
location: WorkspaceStore.Location.Preferences
Actions.openPreferences.listen(@_openPreferences)
ipcRenderer.on 'open-preferences', => @_openPreferences()
_openPreferences: ->
ipcRenderer.send 'command', 'application:show-main-window'
if WorkspaceStore.topSheet() isnt WorkspaceStore.Sheet.Preferences
Actions.pushSheet(WorkspaceStore.Sheet.Preferences)
deactivate: ->
serialize: -> @state