fix(logout): Quick fix for infinite logout issue

This commit is contained in:
Ben Gotow 2015-03-16 13:42:20 -07:00
parent b43a79a75b
commit 8d0ec33b3c
3 changed files with 17 additions and 8 deletions

View file

@ -583,7 +583,7 @@ class Atom extends Model
'atom-workspace:add-account': =>
@displayOnboardingWindow('add-account')
'atom-workspace:logout': =>
@logout() if @isLoggedIn()
@logout()
# Make sure we can't be made so small that the interface looks like crap
@getCurrentWindow().setMinimumSize(875, 500)
@ -623,11 +623,12 @@ class Atom extends Model
@setAutoHideMenuBar(true) if @config.get('core.autoHideMenuBar')
logout: ->
Actions = require './flux/actions'
Actions.logout()
@config.set('inbox', null)
@hide()
@displayOnboardingWindow()
if @isLoggedIn()
@config.set('inbox', null)
Actions = require './flux/actions'
Actions.logout()
@hide()
@displayOnboardingWindow()
displayComposer: (draftLocalId = null, options={}) ->
ipc.send('show-composer-window', _.extend(options, {draftLocalId}))

View file

@ -102,7 +102,7 @@ DatabaseStore = Reflux.createStore
for key, klass of classMap
callback(klass) if klass.attributes
openDatabase: (options = {createTables: false}) ->
openDatabase: (options = {createTables: false}, callback) ->
app = remote.getGlobal('atomApplication')
app.prepareDatabase @_dbPath, =>
database = new DatabaseProxy(@_dbPath)
@ -119,12 +119,14 @@ DatabaseStore = Reflux.createStore
tx.executeInSeries(queries)
.then =>
@_db = database
callback() if callback
.catch ->
# An error occured - most likely a schema change. Log the user out so the
# database is compeltely reset.
atom.logout()
else
@_db = database
callback() if callback
teardownDatabase: (callback) ->
app = remote.getGlobal('atomApplication')
@ -221,7 +223,10 @@ DatabaseStore = Reflux.createStore
onLogout: ->
@teardownDatabase =>
@openDatabase({createTables: @_root})
@openDatabase {createTables: @_root}, =>
# Signal that different namespaces (ie none) are now available
Namespace = require '../models/namespace'
@trigger({objectClass: Namespace.name})
persistModel: (model) ->
@inTransaction {}, (tx) =>

View file

@ -71,6 +71,9 @@ ThreadStore = Reflux.createStore
_onNamespaceChanged: ->
@_namespaceId = NamespaceStore.current()?.id
@_items = []
@trigger(@)
Actions.selectThreadId(null)
@fetchFromCache()
@fetchFromAPI()