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..6d69c486038 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -168,7 +168,8 @@ const doAction = (action) => { break case appConstants.APP_ON_CLEAR_BROWSING_DATA: - if (action.clearDataDetail.get('browserHistory') && !getSetting(settings.PAYMENTS_ENABLED)) reset(true) + // TODO + // if (action.clearDataDetail.get('browserHistory') && !getSetting(settings.PAYMENTS_ENABLED)) reset(true) break case appConstants.APP_IDLE_STATE_CHANGED: 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()}>