Mailspring/internal_packages/onboarding/lib/page-router-store.coffee
Drew Regitsky d40f3e3fdb New onboarding flow, uses new Nylas auth
Summary:
Depends on D2049
This change replaces the onboarding flow to include new graphics, copy, and
support for the new Nylas auth flow. New account choosing UI presents a list
of account types, rather than guessing based on an entered email. Pages before
and after introduce the user to different features of the client.

Known issue: Polling for gmail account connection works, but continues even if
you leave the page.

Test Plan: Manual testing.

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2050
2015-09-22 20:11:51 -07:00

55 lines
1.5 KiB
CoffeeScript

Reflux = require 'reflux'
OnboardingActions = require './onboarding-actions'
NylasStore = require 'nylas-store'
ipc = require 'ipc'
url = require 'url'
return unless atom.getWindowType() is "onboarding"
class PageRouterStore extends NylasStore
constructor: ->
atom.onWindowPropsReceived @_onWindowPropsChagned
@_page = atom.getWindowProps().page ? ''
@_pageData = atom.getWindowProps().pageData ? {}
@_pageStack = [{page: @_page, pageData: @_pageData}]
@listenTo OnboardingActions.moveToPreviousPage, @_onMoveToPreviousPage
@listenTo OnboardingActions.moveToPage, @_onMoveToPage
@listenTo OnboardingActions.nylasAccountReceived, @_onNylasAccountReceived
_onNylasAccountReceived: (account) =>
tokens = atom.config.get('tokens') || []
tokens.push({
provider: 'nylas'
identifier: account.email_address
access_token: account.auth_token
})
atom.config.set('tokens', tokens)
atom.config.save()
@_onMoveToPage('initial-preferences', {account})
_onWindowPropsChagned: ({page, pageData}={}) =>
@_onMoveToPage(page, pageData)
page: -> @_page
pageData: -> @_pageData
connectType: ->
@_connectType
_onMoveToPreviousPage: ->
current = @_pageStack.pop()
prev = @_pageStack.pop()
@_onMoveToPage(prev.page, prev.pageData)
_onMoveToPage: (page, pageData={}) ->
@_pageStack.push({page, pageData})
@_page = page
@_pageData = pageData
@trigger()
module.exports = new PageRouterStore()