Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Clear notifications for origin when tab is closed
Browse files Browse the repository at this point in the history
Fix #3169

Auditors: @bbondy
  • Loading branch information
diracdeltas committed Aug 16, 2016
1 parent c0dc16b commit e30ab74
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/appActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ Hides a message box in the notification bar



### clearMessageBoxes(origin)

Clears all message boxes for a given origin.

**Parameters**

**origin**: `string`, Clears all message boxes for a given origin.



### addWord(word, learn)

Adds a word to the dictionary
Expand Down
11 changes: 11 additions & 0 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,17 @@ const appActions = {
})
},

/**
* Clears all message boxes for a given origin.
* @param {string} origin
*/
clearMessageBoxes: function (origin) {
AppDispatcher.dispatch({
actionType: AppConstants.APP_CLEAR_MESSAGE_BOXES,
origin
})
},

/**
* Adds a word to the dictionary
* @param {string} word - The word to add
Expand Down
4 changes: 4 additions & 0 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ const windowActions = {
*/
closeFrame: function (frames, frameProps, forceClosePinned) {
const ipc = global.require('electron').ipcRenderer
const origin = siteUtil.getOrigin(frameProps.get('location'))
if (origin) {
appActions.clearMessageBoxes(origin)
}
// If the frame was full screen, exit
if (frameProps && frameProps.get('isFullScreen')) {
webviewActions.setFullScreen(false)
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const AppConstants = {
APP_CLEAR_DATA: _,
APP_SHOW_MESSAGE_BOX: _, /** @param {Object} detail */
APP_HIDE_MESSAGE_BOX: _, /** @param {string} message */
APP_CLEAR_MESSAGE_BOXES: _, /** @param {string} origin */
APP_ADD_WORD: _, /** @param {string} word, @param {boolean} learn */
APP_SET_DICTIONARY: _ /** @param {string} locale */
}
Expand Down
5 changes: 5 additions & 0 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@ const handleAppAction = (action) => {
return notification.get('message') === action.message
}))
break
case AppConstants.APP_CLEAR_MESSAGE_BOXES:
appState = appState.set('notifications', appState.get('notifications').filterNot((notification) => {
return notification.get('frameOrigin') === action.origin
}))
break
case AppConstants.APP_ADD_WORD:
let listType = 'ignoredWords'
if (action.learn) {
Expand Down

1 comment on commit e30ab74

@bbondy
Copy link
Member

@bbondy bbondy commented on e30ab74 Aug 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++
At some point we have to revisit this and clear by frame key or tabId and not only origin.

Please sign in to comment.