Added clear app data and clear cache options

This commit is contained in:
Gary Moon 2016-02-23 18:19:52 -05:00
parent 76fe17e39f
commit e4a4476e35
1 changed files with 38 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import {Menu, shell, clipboard} from 'electron';
import {Menu, shell, clipboard, dialog} from 'electron';
/**
*
@ -129,6 +129,43 @@ function createMenu(nativefierVersion, onQuit, onGoBack, onGoForward, onZoomIn,
onZoomOut();
}
},
{
label: 'Clear App Data',
click: (item, focusedWindow) => {
if (focusedWindow) {
dialog.showMessageBox(focusedWindow, {
type:"warning",
buttons:["Yes","Cancel"],
defaultId: 1,
title:"Clear cache confirmation",
message:"This will clear all data (cookies, local storage etc) from this app. \nAre you sure you wish to proceed?"
}, (response) => {
if (response === 0) {
focusedWindow.webContents.session.clearStorageData({},
() => {
focusedWindow.webContents.session.clearCache(() => {
focusedWindow.reload();
});
});
}
});
} else { //FIXME: Not sure what to do here
dialog.showErrorBox("No focused window", "No focused window");
}
}
},
{
label: 'Clear Cache',
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.session.clearCache(() => {
focusedWindow.reload();
});
} else { //FIXME: Not sure what to do here
dialog.showErrorBox("No focused window", "No focused window");
}
}
},
{
label: 'Toggle Window Developer Tools',
accelerator: (() => {