lossless-cut/public/configStore.js

65 wiersze
1.4 KiB
JavaScript
Czysty Zwykły widok Historia

2020-04-17 15:58:10 +00:00
const Store = require('electron-store');
const defaults = {
defaults: {
captureFormat: 'jpeg',
customOutDir: undefined,
keyframeCut: true,
autoMerge: false,
autoDeleteMergedSegments: true,
2020-04-17 15:58:10 +00:00
timecodeShowFrames: false,
invertCutSegments: false,
autoExportExtraStreams: true,
exportConfirmEnabled: true,
2020-04-17 15:58:10 +00:00
askBeforeClose: false,
enableAskForImportChapters: true,
enableAskForFileOpenAction: true,
2020-04-17 15:58:10 +00:00
muted: false,
autoSaveProjectFile: true,
wheelSensitivity: 0.2,
language: undefined,
2020-05-17 12:24:44 +00:00
ffmpegExperimental: false,
preserveMovData: false,
2020-12-11 22:43:32 +00:00
movFastStart: true,
avoidNegativeTs: 'make_zero',
hideNotifications: undefined,
2020-11-27 21:43:06 +00:00
autoLoadTimecode: false,
segmentsToChapters: false,
preserveMetadataOnMerge: false,
2020-12-11 20:29:40 +00:00
simpleMode: true,
2020-04-17 15:58:10 +00:00
},
};
let store;
async function init() {
for (let i = 0; i < 5; i += 1) {
try {
store = new Store(defaults);
return;
} catch (err) {
// eslint-disable-next-line no-await-in-loop
await new Promise(r => setTimeout(r, 2000));
console.error('Failed to create config store, retrying', err);
}
}
throw new Error('Timed out while creating config store');
}
function get(key) {
return store.get(key);
}
function set(key, val) {
if (val === undefined) store.delete(key);
else store.set(key, val);
}
module.exports = {
init,
get,
set,
};