diff --git a/internal_packages/preferences/lib/tabs/preferences-accounts.cjsx b/internal_packages/preferences/lib/tabs/preferences-accounts.cjsx index 5279c6951..8a688b5f7 100644 --- a/internal_packages/preferences/lib/tabs/preferences-accounts.cjsx +++ b/internal_packages/preferences/lib/tabs/preferences-accounts.cjsx @@ -107,10 +107,14 @@ class PreferencesAccounts extends React.Component return [] unless @props.config tokens = @props.config.get('tokens') || [] - token = _.find tokens, (token) -> - token.provider is 'nylas' and token.identifier is account.emailAddress + token = _.find tokens, (t) -> + t.provider is 'nylas' and t.identifier is account.emailAddress tokens = _.without(tokens, token) + if not token + console.warn("Could not find nylas token for email address #{account.emailAddress}") + return + DatabaseStore.unpersistModel(account).then => # TODO: Delete other mail data EdgehillAPI.unlinkToken(token)