diff --git a/app/browser/menu.js b/app/browser/menu.js index 17469c71e22..e4ef286b454 100644 --- a/app/browser/menu.js +++ b/app/browser/menu.js @@ -693,11 +693,11 @@ const doAction = (action) => { } break case appConstants.APP_ON_CLEAR_BROWSING_DATA: - if (action.clearDataDetail.get('browserHistory')) { - appDispatcher.waitFor([appStore.dispatchToken], () => { + appDispatcher.waitFor([appStore.dispatchToken], () => { + if (appStore.getState().getIn(['clearBrowsingDataDefaults', 'browserHistory'])) { createMenu() - }) - } + } + }) break case windowConstants.WINDOW_CLICK_MENUBAR_SUBMENU: appDispatcher.waitFor([appStore.dispatchToken], () => { diff --git a/app/browser/reducers/sitesReducer.js b/app/browser/reducers/sitesReducer.js index a2ea7d0ecff..e006312a052 100644 --- a/app/browser/reducers/sitesReducer.js +++ b/app/browser/reducers/sitesReducer.js @@ -42,7 +42,7 @@ const sitesReducer = (state, action, immutableAction) => { state = siteCache.loadLocationSiteKeysCache(state) break case appConstants.APP_ON_CLEAR_BROWSING_DATA: - if (immutableAction.getIn(['clearDataDetail', 'browserHistory'])) { + if (state.getIn(['clearBrowsingDataDefaults', 'browserHistory'])) { state = state.set('sites', siteUtil.clearHistory(state.get('sites'))) filtering.clearHistory() } diff --git a/app/ledger.js b/app/ledger.js index 1217cd24e2f..941400a56bd 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -56,7 +56,6 @@ const uuid = require('uuid') const appActions = require('../js/actions/appActions') const appConfig = require('../js/constants/appConfig') const appConstants = require('../js/constants/appConstants') -const appDispatcher = require('../js/dispatcher/appDispatcher') const messages = require('../js/constants/messages') const settings = require('../js/constants/settings') const request = require('../js/lib/request') @@ -145,7 +144,7 @@ let notificationTryPaymentsMessage let notificationTimeout = null // TODO(bridiver) - create a better way to get setting changes -const doAction = (action) => { +const doAction = (state, action) => { var i, publisher /* TBD: handle @@ -163,12 +162,26 @@ const doAction = (action) => { } switch (action.actionType) { + case appConstants.APP_SET_STATE: + init() + break + + case appConstants.APP_BACKUP_KEYS: + state = backupKeys(state, action) + break + + case appConstants.APP_RECOVER_WALLET: + state = recoverKeys(state, action) + break + case appConstants.APP_SHUTTING_DOWN: quit() break case appConstants.APP_ON_CLEAR_BROWSING_DATA: - if (action.clearDataDetail.get('browserHistory') && !getSetting(settings.PAYMENTS_ENABLED)) reset(true) + if (state.getIn(['clearBrowsingDataDefaults', 'browserHistory']) && !getSetting(settings.PAYMENTS_ENABLED)) { + reset(true) + } break case appConstants.APP_IDLE_STATE_CHANGED: @@ -264,6 +277,8 @@ const doAction = (action) => { default: break } + + return state } /* @@ -272,7 +287,6 @@ const doAction = (action) => { var init = () => { try { - appDispatcher.register(doAction) initialize(getSetting(settings.PAYMENTS_ENABLED)) } catch (ex) { console.log('ledger.js initialization failed: ' + ex.toString() + '\n' + ex.stack) } } @@ -2250,5 +2264,6 @@ module.exports = { backupKeys: backupKeys, quit: quit, boot: boot, - reset: reset + reset: reset, + doAction } diff --git a/app/renderer/components/main/clearBrowsingDataPanel.js b/app/renderer/components/main/clearBrowsingDataPanel.js index 6e44f73733f..de0fa9186ea 100644 --- a/app/renderer/components/main/clearBrowsingDataPanel.js +++ b/app/renderer/components/main/clearBrowsingDataPanel.js @@ -7,6 +7,7 @@ const Immutable = require('immutable') const ipc = require('electron').ipcRenderer // Components +const ReduxComponent = require('../reduxComponent') const Dialog = require('../common/dialog') const Button = require('../common/button') const SwitchControl = require('../common/switchControl') @@ -20,6 +21,7 @@ const { // Actions const appActions = require('../../../../js/actions/appActions') +const windowActions = require('../../../../js/actions/windowActions') // Constants const messages = require('../../../../js/constants/messages') @@ -36,71 +38,100 @@ class ClearBrowsingDataPanel extends React.Component { this.onToggleAutofillData = this.onToggleSetting.bind(this, 'autofillData') this.onToggleSavedSiteSettings = this.onToggleSetting.bind(this, 'savedSiteSettings') this.onClear = this.onClear.bind(this) - this.state = { - clearBrowsingDataDetail: props.clearBrowsingDataDefaults ? props.clearBrowsingDataDefaults : Immutable.Map() - } + this.onCancel = this.onCancel.bind(this) } - onToggleSetting (setting) { - this.setState(({clearBrowsingDataDetail}) => ({ - clearBrowsingDataDetail: clearBrowsingDataDetail.update(setting, isChecked => !isChecked) - })) + + onToggleSetting (setting, e) { + appActions.onToggleBrowsingData(setting, e.target.value) } + onClear () { - appActions.onClearBrowsingData(this.state.clearBrowsingDataDetail) - this.props.onHide() - let detail = this.state.clearBrowsingDataDetail - if (detail.get('allSiteCookies') && detail.get('browserHistory') && - detail.get('cachedImagesAndFiles')) { + appActions.onClearBrowsingData() + this.onHide() + + if ( + this.props.allSiteCookies && + this.props.browserHistory && + this.props.cachedImagesAndFiles + ) { ipc.send(messages.PREFS_RESTART) } } + + onCancel () { + appActions.onCancelBrowsingData() + this.onHide() + } + + onHide () { + windowActions.setClearBrowsingDataPanelVisible(false) + } + + mergeProps (state, ownProps) { + const tempData = state.get('tempClearBrowsingData', Immutable.Map()) + const data = state.get('clearBrowsingDataDefaults', Immutable.Map()).merge(tempData) + + const props = {} + props.allSiteCookies = data.get('allSiteCookies') + props.browserHistory = data.get('browserHistory') + props.downloadHistory = data.get('downloadHistory') + props.cachedImagesAndFiles = data.get('cachedImagesAndFiles') + props.savedPasswords = data.get('savedPasswords') + props.allSiteCookies = data.get('allSiteCookies') + props.autocompleteData = data.get('autocompleteData') + props.autofillData = data.get('autofillData') + props.savedSiteSettings = data.get('savedSiteSettings') + + return props + } + render () { - return + return e.stopPropagation()}>