mirror of
https://github.com/LinoSchmidt/StickExporterTX.git
synced 2026-03-21 01:51:15 +01:00
Fixed settings not repairing if file is broken
This commit is contained in:
@@ -7,6 +7,16 @@ function getXMLChild(doc:Document, child:string) {
|
|||||||
return String(doc.getElementsByTagName(child)[0].childNodes[0].nodeValue);
|
return String(doc.getElementsByTagName(child)[0].childNodes[0].nodeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultSettings = {
|
||||||
|
fps: 30,
|
||||||
|
width: 540,
|
||||||
|
stickDistance: 5,
|
||||||
|
stickMode2: true,
|
||||||
|
log: '"None"',
|
||||||
|
output: "None"
|
||||||
|
}
|
||||||
|
|
||||||
|
let loadedSuccessfully = true;
|
||||||
const settingList = await fetch(SettingPath).then(function(response){
|
const settingList = await fetch(SettingPath).then(function(response){
|
||||||
return response.text();
|
return response.text();
|
||||||
}).then(function(data){
|
}).then(function(data){
|
||||||
@@ -23,24 +33,18 @@ const settingList = await fetch(SettingPath).then(function(response){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
logger.errorMSG(error);
|
logger.warning("Could not load settings: " + error.toString() + "\n Creating new settings file...");
|
||||||
|
loadedSuccessfully = false;
|
||||||
return {
|
return defaultSettings;
|
||||||
fps: 30,
|
|
||||||
width: 540,
|
|
||||||
stickDistance: 5,
|
|
||||||
stickMode2: true,
|
|
||||||
log: '"None"',
|
|
||||||
output: "None"
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
if(!loadedSuccessfully) updateSettings({});
|
||||||
|
|
||||||
function settingListLoadDefault() {
|
function settingListLoadDefault() {
|
||||||
updateSettings({
|
updateSettings({
|
||||||
fps: 30,
|
fps:defaultSettings.fps,
|
||||||
width: 540,
|
width:defaultSettings.width,
|
||||||
stickDistance: 5,
|
stickDistance:defaultSettings.stickDistance,
|
||||||
stickMode2: true
|
stickMode2:defaultSettings.stickMode2
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,5 +98,5 @@ function updateSettings(optiones:{fps?:number, width?:number, stickDistance?:num
|
|||||||
export {
|
export {
|
||||||
updateSettings,
|
updateSettings,
|
||||||
settingListLoadDefault,
|
settingListLoadDefault,
|
||||||
settingList
|
settingList,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user