Mailspring/internal_packages/onboarding/lib/page-router-store.coffee
Evan Morikawa e44a7e28b6 feat(onboarding): refactor onboarding flow
Summary:
Add spinner and refactor container view to be router

add `NylasStore` as a global importable. specs for APIEnv

login page fixes

add old fixes to container view

finish extracting pages

fix onboarding flow

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1652
2015-06-17 15:58:58 -07:00

41 lines
1 KiB
CoffeeScript

Reflux = require 'reflux'
OnboardingActions = require './onboarding-actions'
NylasStore = require 'nylas-store'
ipc = require 'ipc'
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
_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()