-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #8 - forces Electron to clear cache on start
- Loading branch information
1 parent
9f073c7
commit 4e386f2
Showing
4 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const NodeHelper = require('node_helper'); | ||
const {BrowserWindow} = require('electron') | ||
|
||
module.exports = NodeHelper.create({ | ||
|
||
socketNotificationReceived: function(notification, payload) { | ||
switch(notification) { | ||
case "CLEAR_CACHE": | ||
try { | ||
const win = BrowserWindow.getAllWindows()[0]; | ||
const ses = win.webContents.session; | ||
|
||
ses.clearCache(() => { | ||
console.log("Electron's cache successfully cleared."); | ||
this.sendSocketNotification("ELECTRON_CACHE_CLEARED", {}); | ||
}); | ||
} catch (e) { | ||
// We'll get a TypeError if MM is being run in server only mode because Electron won't be running the app - if that's the case we can just say the cache has been cleared and call it a day | ||
if (e.name == "TypeError") { | ||
this.sendSocketNotification("ELECTRON_CACHE_CLEARED", {}); | ||
} else { | ||
console.log("WallberryTheme ERROR: ", e); | ||
} | ||
|
||
} | ||
|
||
break; | ||
} | ||
} | ||
}); |