Browse Source

Guard service removal code properly.

Fixes #166.
pull/3202/head
TheGoddessInari 5 years ago
parent
commit
a5e13d5544
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

@ -63,10 +63,12 @@ Ext.define('Hamsket.view.main.MainController', {
if ( t.id !== 'hamsketTab' && t.id !== 'tbfill' && t.record.get('enabled') ) { if ( t.id !== 'hamsketTab' && t.id !== 'tbfill' && t.record.get('enabled') ) {
const rec = store.getById(t.record.get('id')); const rec = store.getById(t.record.get('id'));
if ( align === 'right' ) i--; if ( align === 'right' ) i--;
if (rec) {
rec.set('align', align); rec.set('align', align);
rec.set('position', i); rec.set('position', i);
rec.save(); rec.save();
} }
}
else if ( t.id === 'tbfill' ) { else if ( t.id === 'tbfill' ) {
align = 'right'; align = 'right';
} }
@ -147,20 +149,19 @@ Ext.define('Hamsket.view.main.MainController', {
// Get Tab // Get Tab
// Clear all trash data // Clear all trash data
const tab = Ext.getCmp('tab_'+serviceId); const tab = Ext.getCmp('tab_'+serviceId);
const webview = tab.getWebView(); clearData(tab, resolve);
clearData(webview, 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(webview, tab, resolve) { function clearData(tab, resolve) {
webview.getWebContents().clearHistory(); tab.getWebContents().clearHistory();
webview.getWebContents().session.flushStorageData(); tab.getWebContents().session.flushStorageData();
webview.getWebContents().session.clearCache() tab.getWebContents().session.clearCache()
.then(webview.getWebContents().session.clearStorageData) .then(tab.getWebContents().session.clearStorageData)
.then(webview.getWebContents().session.cookies.flushStore) .then(tab.getWebContents().session.cookies.flushStore)
.then(function() { .finally(function() {
// Remove record from localStorage // Remove record from localStorage
Ext.getStore('Services').remove(rec); Ext.getStore('Services').remove(rec);
// Close tab // Close tab

Loading…
Cancel
Save