Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'electron-json-storage' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
cleanupAndExit() {
storage.clear((error) => {
if (error) throw error;
// console.log(app.getPath('userData'));
app.exit(0);
});
}
}
function recordStopStart() {
if (recordingState == 0) {
//wirecast.wirecastStartRecord();
hyperdeck.record();
//stopwatch.start();
console.log( 'Started Recording' );
recordingState = 1;
tallyRecord.style.backgroundColor = "#ff4d4d";
tallyRecord.innerText = "Stop";
var d = new Date();
var d2 = d.toISOString().slice(0,10);
storage.get('recording-name', function(error, data) {
if (error) throw error;
tcToTxt.write(data.recordingName+" - "+d2+"\n");
});
for (var i = 0; i < 14; i++) {
storage.get('sd'+i+'-button', function(error, data) {
if (error) throw error;
if (data.class == "hyperdeckRec") {
var sd = data.name - 1 + 1;
myStreamDeck.fillImageFromFile(sd, path.resolve(__dirname, 'assets/stream-deck/stop-red.png')).then(() => {
});
}
});
};
} else {
// STOP RECORDING
storage.has('setup', function (error, hasKey) {
if (error) {
throw error;
}
if (!hasKey) {
console.log('Application is yet to be setup.');
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
appCreate();
} else {
//Initiate endless poll
setInterval(queryCheck, refreshinterval * 1000);
queryCheck();
storage.get('setup', function (error, data) {
if (error) {
throw error;
}
let userId = data.userId;
let password = data.password;
login(userId, password);
});
}
});
function (filePath) {
if (filePath) {
// fs.writeFile('path.txt', filePath, function (err, data) {
// if (err) console.log(err);
// });
// console.log(walkSync(filePath[0]));
storage.set('path', { path: filePath }, function (error) {
if (error) throw error
})
scanDir(filePath)
}
}
)
}).then((data) => {
if (data.version !== $scope.appVersion.toString()) {
$scope.showUpdate = true;
}
}, () => {
console.log('Error getting update notification');
});
$scope.updateApp = () => {
shell.openExternal('http://ffftp.site/download/' + $scope.appVersion);
};
// Load Favorites
const storage = require('electron-json-storage');
$scope.favorites = [];
storage.has('favorites', (error, hasKey) => {
if (error) throw error;
if (hasKey) {
storage.get('favorites', (error, data) => {
if (error) throw error;
$timeout(() => {
$scope.favorites = data;
console.log('FAVORITES');
console.log(data);
}, 0);
});
} else {
console.log('No favs');
}
});
Storage.get("moveApp", async (error, value) => {
if (value) {
try {
const moved = await moveToApplications();
} catch (error) {
console.log(error);
}
} else {
console.log("user choosed to not move the app!");
}
});
}
});
// Set default property for nothing-found-window
Storage.has("noting-found-window", (error, hasKey) => {
if (error) throw error;
if (!hasKey) {
Storage.set("noting-found-window", true, error => {
if (error) throw error;
nothingFoundWindowValue = true;
});
}
});
}
app.setAboutPanelOptions({
applicationName: "Caption",
applicationVersion: pkg.version,
copyright: "Made with 💖 by Giel Cobben. \n www.gielcobben.com",
credits: `With the invaluable help of: \n OpenSubtitles.org and Addic7ed.com`,
version: pkg.version
function updateAllUserServiceConfigurationsSince_1_9_0 () {
// 1.9.0 introduced userAgents per service. See #158
// TODO:
// patch all user-services:
// add: userAgentDefault
const storage = require('electron-json-storage')
writeLog('info', 'updateAllUserServiceConfigurationsSince_1_9_0 ::: Starting to validate all user service configurations')
// loop over all json files - and see if we need to patch something
storage.getAll(function (error, data) {
if (error) {
writeLog('error', 'updateAllUserServiceConfigurationsSince_1_9_0 ::: Got error while trying to fetch all service configs. Error: ' + error)
throw error
}
// show object which contains all config files
// writeLog("info", "loadEnabledUserServices ::: Object: " + data);
// console.error(data);
var userAgentDefaultMissing
var newUserAgentDefaultString
var userAgentCustomMissing
var userUserAgentCustomString
// loop over upper object
for (var key in data) {
function loadEnabledUserServices () {
const storage = require('electron-json-storage')
writeLog('info', 'loadEnabledUserServices ::: Starting to fetch all user configured service files')
// loop over all json files - add tab for the enabled ones
storage.getAll(function (error, data) {
if (error) {
throw error
}
// show object which contains all config files
// writeLog("info", "loadEnabledUserServices ::: Object: " + data);
// console.error(data);
// loop over upper object
for (var key in data) {
if (data.hasOwnProperty(key)) {
writeLog('info', 'loadEnabledUserServices ::: ' + key)
writeLog('info', 'loadEnabledUserServices ::: ' + key + ' -> ' + data[key])
// show enabled configured service
if (data[key].serviceEnableStatus === true) {
function updateAllUserServiceConfigurationsSince_1_8_0 () {
// changes from 1.7.0 to 1.8.0:
// - inject files got re-structured. Path & names are stored in the user-services configuration files
//
const storage = require('electron-json-storage')
writeLog('info', 'updateAllUserServiceConfigurationsSince_1_8_0 ::: Starting to validate all user service configurations')
// loop over all json files - and see if we need to patch something
storage.getAll(function (error, data) {
if (error) {
writeLog('error', 'updateAllUserServiceConfigurationsSince_1_8_0 ::: Got error while trying to fetch all service configs. Error: ' + error)
throw error
}
// show object which contains all config files
// writeLog("info", "loadEnabledUserServices ::: Object: " + data);
// console.error(data);
var shouldConfigBeUpdated = false
var newInjectCodePath
// loop over upper object
for (var key in data) {
if (data.hasOwnProperty(key)) {
writeLog('info', 'updateAllUserServiceConfigurationsSince_1_8_0 ::: ' + key + ' -> ' + data[key])
const path = require('path');
const StreamDeck = require('elgato-stream-deck');
const fs = require('fs');
const homedir = require('homedir');
const objChange = require('object-change');
// CREATE TXT FILE FOR MARKERS
var tcToTxt = fs.createWriteStream(homedir()+'/desktop/button-switch-log.txt', {
flags: 'a' // 'a' means appending (old data will be preserved)
});
// SETTINGS JSON FILE //
// GRAB SAVED IP ADDRESS FROM STORAGE
const dataPath = storage.getDataPath();
//console.log(dataPath);
storage.get('atem-ip-address', function(error, data) {
if (error) throw error;
if (data.atemIPAddress === undefined) {
document.getElementById('idAddressInput').value = "";
} else {
document.getElementById('idAddressInput').value = data.atemIPAddress;
};
});
storage.get('hyperdeck-ip-address', function(error, data) {
if (error) throw error;
if (data.hyperdeckIPAddress === undefined) {
document.getElementById('ipAddressInputHyperDeck').value = "";
} else {
document.getElementById('ipAddressInputHyperDeck').value = data.hyperdeckIPAddress;
};