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

Loading…
Cancel
Save