Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function scheduleRandomNote (scheduleVal = storeSettings.getItemSync('schedule')) {
let rule
if (scheduleVal === '*/5 * * * *') {
rule = '*/5 * * * *' // every 5 minutes
} else {
rule = new schedule.RecurrenceRule()
rule.dayOfWeek = [0, new schedule.Range(0, 7)]
rule.hour = scheduleVal
rule.minute = 0
// it's impt to understand we're only logging time, not actually setting it
// since the event doesn't do this for us the first time
// we need an accurate value to determine missed schedules
let thisScheduledVal = defineSchedule(scheduleVal)
storeSettings.setItemSync('scheduledRuntime', thisScheduledVal)
storeSettings.setItemSync('scheduledRuntimeLocal', thisScheduledVal.format(momentFormat))
log.info(`scheduled: ${thisScheduledVal}`)
log.info(`scheduled-settings-value: ${scheduleVal}`)
}
let j = schedule.scheduleJob(rule, () => {
mainWindow.webContents.send('trigger-random-note')
})
j.on('scheduled', (event) => {
storeSettings.setItemSync('scheduledRuntime', event)
log.info(`scheduled: ${event}`)
log.info(`scheduled-settings-value: ${scheduleVal}`)
})
j.on('run', (event) => {
function setPortForLightId(lightId, value)
{
var key = formatUUID(lightId);
if (storage)
storage.setItemSync(key, value);
}
handleSave () {
this.logChangedSettings()
storeSettings.setItemSync('schedule', this.settings.schedule)
storeSettings.setItemSync('openWith', this.settings.openWith)
storeSettings.setItemSync('shortcutKey', this.settings.shortcutKey.join('+'))
ipc.send('set-global-shortcuts', this.settings.shortcutKey.join('+'))
ipc.send('reschedule-notes', this.settings.schedule)
$('#settings').modal('hide')
},
logChangedSettings () {
function loadSettings () {
for (const [key, value] of DEFAULT_SETTINGS) {
if (storeSettings.getItemSync(key) === undefined || null || '') {
storeSettings.setItemSync(key, value)
}
}
}
addAdmin(id) {
Winston.info('ClientControls -> addAdmin', id);
this.administrators.push(id);
storage.setItemSync('administrators', this.administrators);
}
sendPlaylist({ songs, currentSong }) {
static set( key, value ) {
brain.setItemSync( key, value );
}
};
function setLightBriForLightId(lightId, value)
{
if (storage === null || storage === undefined) {
RED.log.warn("storage is null in setLightBriForLightId");
return null;
}
if (lightId === null || lightId === undefined) {
RED.log.warn("lightId is null");
return null;
}
var key = formatUUID(lightId) + "_bri";
storage.setItemSync(key, value);
}
setItemSync:function(key,value) {
return node_persist.setItemSync(key,value);
}
};
function saveAccounts(accountName, accounts, masterPassword){
try {
var cipher = crypto.createCipher('aes-256-cbc', masterPassword);
var encrypted = cipher.update(JSON.stringify(accounts), 'utf8', 'hex') + cipher.final('hex');
storage.setItemSync(accountName, encrypted);
return accounts;
} catch (e) {
throw new Error(e.message);
}
}