Streamline code to clean logs based on version number
This commit is contained in:
parent
12f1932d02
commit
f2a63c99ed
2 changed files with 17 additions and 1 deletions
|
@ -252,7 +252,10 @@
|
|||
await storage.put('version', currentVersion);
|
||||
|
||||
if (newVersion) {
|
||||
if (currentVersion === '1.14.2' || currentVersion === '1.15.0-beta.2') {
|
||||
if (
|
||||
lastVersion &&
|
||||
window.isBeforeVersion(lastVersion, 'v1.15.0-beta.4')
|
||||
) {
|
||||
await window.Signal.Logs.deleteAll();
|
||||
window.restart();
|
||||
}
|
||||
|
|
13
preload.js
13
preload.js
|
@ -4,6 +4,7 @@
|
|||
console.log('preload');
|
||||
|
||||
const electron = require('electron');
|
||||
const semver = require('semver');
|
||||
|
||||
const { deferredToPromise } = require('./js/modules/deferred_to_promise');
|
||||
|
||||
|
@ -29,6 +30,18 @@ window.getExpiration = () => config.buildExpiration;
|
|||
window.getNodeVersion = () => config.node_version;
|
||||
window.getHostName = () => config.hostname;
|
||||
|
||||
window.isBeforeVersion = (toCheck, baseVersion) => {
|
||||
try {
|
||||
return semver.lt(toCheck, baseVersion);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
`isBeforeVersion error: toCheck: ${toCheck}, baseVersion: ${baseVersion}`,
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
window.wrapDeferred = deferredToPromise;
|
||||
|
||||
const ipc = electron.ipcRenderer;
|
||||
|
|
Loading…
Reference in a new issue