diff --git a/internal_packages/notifications/lib/notifications-store.coffee b/internal_packages/notifications/lib/notifications-store.coffee index 6b17c41d9..2973be6d9 100644 --- a/internal_packages/notifications/lib/notifications-store.coffee +++ b/internal_packages/notifications/lib/notifications-store.coffee @@ -1,6 +1,6 @@ _ = require 'underscore' -Reflux = require 'reflux' {Actions} = require 'nylas-exports' +NylasStore = require 'nylas-store' VERBOSE = false DISPLAY_TIME = 3000 # in ms @@ -34,9 +34,8 @@ class Notification toString: -> "Notification.#{@constructor.name}(#{@tag})" -module.exports = -NotificationStore = Reflux.createStore - init: -> +class NotificationStore extends NylasStore + constructor: -> @_flush() # The notification store listens for user interaction with notififcations @@ -53,12 +52,12 @@ NotificationStore = Reflux.createStore ######### PUBLIC ####################################################### - notifications: -> + notifications: => console.log(JSON.stringify(@_notifications)) if VERBOSE sorted = _.sortBy(_.values(@_notifications), (n) -> -1*(n.creation + n.tag)) _.reject sorted, (n) -> n.sticky - stickyNotifications: -> + stickyNotifications: => console.log(JSON.stringify(@_notifications)) if VERBOSE sorted = _.sortBy(_.values(@_notifications), (n) -> -1*(n.creation + n.tag)) _.filter sorted, (n) -> n.sticky @@ -67,10 +66,10 @@ NotificationStore = Reflux.createStore ########### PRIVATE #################################################### - _flush: -> + _flush: => @_notifications = {} - _postNotification: (notification) -> + _postNotification: (notification) => console.log "Queue Notification.#{notification}" if VERBOSE @_notifications[notification.tag] = notification if notification.expiry? @@ -94,5 +93,7 @@ NotificationStore = Reflux.createStore # If the window matches the given context then we can show a # notification. - _inWindowContext: (context={}) -> + _inWindowContext: (context={}) => return true + +module.exports = new NotificationStore() diff --git a/internal_packages/notifications/spec/notifications-store-spec.coffee b/internal_packages/notifications/spec/notifications-store-spec.coffee index 7b6d94b8a..89957dac0 100644 --- a/internal_packages/notifications/spec/notifications-store-spec.coffee +++ b/internal_packages/notifications/spec/notifications-store-spec.coffee @@ -46,7 +46,7 @@ describe 'NotificationStore', -> it 'should unregister on removeNotification', -> Actions.postNotification({type: 'info', message: 'hi'}) n = NotificationsStore.notifications()[0] - NotificationsStore._removeNotification(n)() + NotificationsStore._removeNotification(n) expect(NotificationsStore.notifications().length).toEqual 0 describe "with a few notifications", -> diff --git a/spec/quoted-html-transformer-spec.coffee b/spec/quoted-html-transformer-spec.coffee index 5d29fd8dd..9a7f6dcee 100644 --- a/spec/quoted-html-transformer-spec.coffee +++ b/spec/quoted-html-transformer-spec.coffee @@ -256,6 +256,18 @@ describe "QuotedHTMLTransformer", ->
""" + + # Test 11: The tag itself is just a quoted text block. + # I believe this is https://sentry.nylas.com/sentry/edgehill/group/8323/ + tests.push + before: """ + + This entire thing is quoted text! + + """ + after: """ + """ + it 'works with these manual test cases', -> for {before, after} in tests opts = keepIfWholeBodyIsQuote: true diff --git a/src/services/quoted-html-transformer.coffee b/src/services/quoted-html-transformer.coffee index e144d397c..8d4dc2979 100644 --- a/src/services/quoted-html-transformer.coffee +++ b/src/services/quoted-html-transformer.coffee @@ -45,8 +45,11 @@ class QuotedHTMLTransformer return doc.children[0].innerHTML else DOMUtils.Mutating.removeElements(quoteElements, options) - childNodes = doc.body.childNodes + # It's possible that the entire body was quoted text and we've removed everything. + return "" unless doc.body + + childNodes = doc.body.childNodes extraTailBrTags = [] for i in [(childNodes.length - 1)..0] by -1 curr = childNodes[i]