Browse Source

Go back to slightly older style RemoveServiceFn, but respecting WebContents.

Fix for a5e13d5.
pull/3202/head
TheGoddessInari 5 years ago
parent
commit
d55af4041d
No known key found for this signature in database
GPG Key ID: 1209B1B7632D69A
  1. 19
      app/view/main/MainController.js

19
app/view/main/MainController.js

@ -139,27 +139,28 @@ Ext.define('Hamsket.view.main.MainController', {
rec.set('enabled', true);
me.onEnableDisableService(null, Ext.getStore('Services').indexOf(rec), true, null, true);
const tab = Ext.getCmp('tab_'+serviceId);
const webview = tab.getWebView();
const webcontents = tab.getWebContents();
webview.addEventListener("did-start-loading", function() {
clearData(tab, resolve);
clearData(webcontents, tab, resolve);
});
} else {
// Get Tab
// Clear all trash data
const tab = Ext.getCmp('tab_'+serviceId);
clearData(tab, resolve);
const webcontents = tab.getWebContents();
clearData(webcontents, tab, resolve);
}
const config = ipc.sendSync('getConfig');
if ( config.default_service === rec.get('id') ) ipc.send('setConfig', Ext.apply(config, { default_service: 'hamsketTab' }));
function clearData(tab, resolve) {
tab.getWebContents().clearHistory();
tab.getWebContents().session.flushStorageData();
tab.getWebContents().session.clearCache()
.then(tab.getWebContents().session.clearStorageData)
.then(tab.getWebContents().session.cookies.flushStore)
function clearData(webcontents, tab, resolve) {
webcontents.clearHistory();
webcontents.session.flushStorageData();
webcontents.session.clearCache()
.then(webcontents.session.clearStorageData)
.then(webcontents.session.cookies.flushStore)
.finally(function() {
// Remove record from localStorage
Ext.getStore('Services').remove(rec);

Loading…
Cancel
Save