diff --git a/docs/appActions.md b/docs/appActions.md index 00f97f732c6..55876824dd0 100644 --- a/docs/appActions.md +++ b/docs/appActions.md @@ -766,7 +766,7 @@ Dispatches a message when a tab is being cloned -### noScriptExceptionsAdded(hostPattern, origins) +### noScriptExceptionsAdded(hostPattern, origins, temporary) Dispatches a message when noscript exceptions are added for an origin @@ -776,6 +776,8 @@ Dispatches a message when noscript exceptions are added for an origin **origins**: `Object.<string, (boolean|number)>`, Dispatches a message when noscript exceptions are added for an origin +**temporary**: `boolean`, Dispatches a message when noscript exceptions are added for an origin + ### setObjectId(objectId, objectPath) diff --git a/js/actions/appActions.js b/js/actions/appActions.js index 93b8a96201f..db3fbe61d0a 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -943,12 +943,14 @@ const appActions = { * Dispatches a message when noscript exceptions are added for an origin * @param {string} hostPattern * @param {Object.} origins + * @param {boolean} temporary */ - noScriptExceptionsAdded: function (hostPattern, origins) { + noScriptExceptionsAdded: function (hostPattern, origins, temporary) { AppDispatcher.dispatch({ actionType: appConstants.APP_ADD_NOSCRIPT_EXCEPTIONS, hostPattern, - origins + origins, + temporary }) }, diff --git a/js/components/noScriptInfo.js b/js/components/noScriptInfo.js index 11a3adfb1ac..db26fc0271e 100644 --- a/js/components/noScriptInfo.js +++ b/js/components/noScriptInfo.js @@ -84,7 +84,7 @@ class NoScriptInfo extends ImmutableComponent { } }) if (checkedOrigins.filter((value) => value !== false).size) { - appActions.noScriptExceptionsAdded(this.origin, checkedOrigins) + appActions.noScriptExceptionsAdded(this.origin, checkedOrigins, this.isPrivate) this.reload() this.props.onHide() } diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 93f051c2e61..51840518c58 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -562,15 +562,18 @@ const handleAppAction = (action) => { break } case appConstants.APP_ADD_NOSCRIPT_EXCEPTIONS: - // Note that this is always cleared on restart or reload, so should not - // be synced or persisted. - let key = 'noScriptExceptions' - if (!action.origins || !action.origins.size) { - // Clear the exceptions - appState = appState.setIn(['siteSettings', action.hostPattern, key], new Immutable.Map()) - } else { - const currentExceptions = appState.getIn(['siteSettings', action.hostPattern, key]) || new Immutable.Map() - appState = appState.setIn(['siteSettings', action.hostPattern, key], currentExceptions.merge(action.origins)) + { + const propertyName = action.temporary ? 'temporarySiteSettings' : 'siteSettings' + // Note that this is always cleared on restart or reload, so should not + // be synced or persisted. + const key = 'noScriptExceptions' + if (!action.origins || !action.origins.size) { + // Clear the exceptions + appState = appState.setIn([propertyName, action.hostPattern, key], new Immutable.Map()) + } else { + const currentExceptions = appState.getIn([propertyName, action.hostPattern, key]) || new Immutable.Map() + appState = appState.setIn([propertyName, action.hostPattern, key], currentExceptions.merge(action.origins)) + } } break case appConstants.APP_UPDATE_LEDGER_INFO: