From 1bf220f1a6dfa52d56cb2afad77f12458e2724be Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 8 Sep 2015 18:38:45 -0700 Subject: [PATCH] fix(draft-list-store): Upgrade draft list store to NylasStore, fix issue where @_view is null --- .../thread-list/lib/draft-list-store.coffee | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/internal_packages/thread-list/lib/draft-list-store.coffee b/internal_packages/thread-list/lib/draft-list-store.coffee index bfb29450e..11b355461 100644 --- a/internal_packages/thread-list/lib/draft-list-store.coffee +++ b/internal_packages/thread-list/lib/draft-list-store.coffee @@ -1,3 +1,4 @@ +NylasStore = require 'nylas-store' Reflux = require 'reflux' _ = require 'underscore' {Message, @@ -8,9 +9,8 @@ _ = require 'underscore' DestroyDraftTask, DatabaseView} = require 'nylas-exports' -module.exports = -DraftListStore = Reflux.createStore - init: -> +class DraftListStore extends NylasStore + constructor: -> @listenTo DatabaseStore, @_onDataChanged @listenTo AccountStore, @_onAccountChanged @listenTo Actions.deleteSelection, @_onDeleteSelection @@ -21,10 +21,10 @@ DraftListStore = Reflux.createStore @listenTo Actions.sendDraftSuccess, => @_view.invalidate() @_createView() - view: -> + view: => @_view - _createView: -> + _createView: => account = AccountStore.current() if @unlisten @@ -43,19 +43,21 @@ DraftListStore = Reflux.createStore @unlisten = @_view.listen => @trigger({}) - _onAccountChanged: -> + _onAccountChanged: => @_createView() - _onDataChanged: (change) -> + _onDataChanged: (change) => return unless change.objectClass is Message.name containsDraft = _.some(change.objects, (msg) -> msg.draft) - return unless containsDraft + return unless containsDraft and @_view @_view.invalidate() - _onDeleteSelection: -> + _onDeleteSelection: => selected = @_view.selection.items() for item in selected Actions.queueTask(new DestroyDraftTask(draftClientId: item.clientId)) @_view.selection.clear() + +module.exports = new DraftListStore()