diff --git a/docs/appActions.md b/docs/appActions.md index 340ce408eaf..3ecaa859835 100644 --- a/docs/appActions.md +++ b/docs/appActions.md @@ -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 diff --git a/js/actions/appActions.js b/js/actions/appActions.js index ee748b2af63..317b50920b1 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -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 diff --git a/js/actions/windowActions.js b/js/actions/windowActions.js index f391f924eda..0656d734a39 100644 --- a/js/actions/windowActions.js +++ b/js/actions/windowActions.js @@ -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) diff --git a/js/constants/appConstants.js b/js/constants/appConstants.js index 0ea8576e485..d7f5e1385d1 100644 --- a/js/constants/appConstants.js +++ b/js/constants/appConstants.js @@ -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 */ } diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 66c1cb67126..b54b60c9fab 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -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) {