By default, mail rules are only applied to new mail as it arrives.
Applying rules to your entire mailbox may take quite a while and
temporarily degrade performance.
{@_renderTasks()}
_renderList: =>
_renderListItemContent: (rule) ->
if rule.disabled
return
If of the following conditions are met: Actions.updateMailRule(rule.id, {conditions}) }
className="well well-matchers"/>
Perform the following actions: Actions.updateMailRule(rule.id, {actions}) }
className="well well-actions"/>
_onReprocessRules: =>
needsMessageBodies = =>
for rule in @state.rules
for condition in rule.conditions
if condition.templateKey is 'body'
return true
return false
if needsMessageBodies()
NylasEnv.showErrorDialog("One or more of your mail rules requires the bodies of messages being processed. These rules can't be run on your entire mailbox.")
task = new ReprocessMailRulesTask(@state.account.id)
Actions.queueTask(task)
_onAddRule: =>
Actions.addMailRule({accountId: @state.account.id})
_onSelectRule: (rule, idx) =>
@setState(selectedRule: rule)
_onDeleteRule: (rule, idx) =>
Actions.deleteMailRule(rule.id)
_onRuleNameEdited: (newName, rule, idx) =>
Actions.updateMailRule(rule.id, {name: newName})
_onRuleConditionModeEdited: (event) =>
Actions.updateMailRule(@state.selectedRule.id, {conditionMode: event.target.value})
_onRuleEnabled: =>
Actions.updateMailRule(@state.selectedRule.id, {disabled: false, disabledReason: null})
_onRulesChanged: =>
next = @stateForAccount(@props.accountId)
nextRules = next.rules
prevRules = @state?.rules || []
added = _.difference(nextRules, prevRules)
if added.length is 1
next.selectedRule = added[0]
@setState(next)
_onTasksChanged: =>
@setState(tasks: TaskQueueStatusStore.tasksMatching(ReprocessMailRulesTask, {}))
module.exports = PreferencesMailRules