From 8d0ec33b3cb438f65037b88dca65e3f28dd05775 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 16 Mar 2015 13:42:20 -0700 Subject: [PATCH] fix(logout): Quick fix for infinite logout issue --- src/atom.coffee | 13 +++++++------ src/flux/stores/database-store.coffee | 9 +++++++-- src/flux/stores/thread-store.coffee | 3 +++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 7db4e9fee..00a723ff0 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -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})) diff --git a/src/flux/stores/database-store.coffee b/src/flux/stores/database-store.coffee index 096cfbe36..223bcbf37 100644 --- a/src/flux/stores/database-store.coffee +++ b/src/flux/stores/database-store.coffee @@ -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) => diff --git a/src/flux/stores/thread-store.coffee b/src/flux/stores/thread-store.coffee index e87e56f39..bedc426e4 100644 --- a/src/flux/stores/thread-store.coffee +++ b/src/flux/stores/thread-store.coffee @@ -71,6 +71,9 @@ ThreadStore = Reflux.createStore _onNamespaceChanged: -> @_namespaceId = NamespaceStore.current()?.id + @_items = [] + @trigger(@) + Actions.selectThreadId(null) @fetchFromCache() @fetchFromAPI()