Skip to content

Commit

Permalink
Merge pull request #479 from saltrafael/fix-erwic-default-settings
Browse files Browse the repository at this point in the history
Fix: cant write to disk erwic settings that match defaultSettings
  • Loading branch information
Jelmerro authored May 17, 2023
2 parents acd0db9 + 708e88a commit 69f7d57
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions app/renderer/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ const defaultSettings = {
"vimcommand": "gvim",
"windowtitle": "%app - %title"
}
const defaultErwicSettings = {
"containernewtab": "s:external",
"containerstartuppage": "s:usematching",
"permissioncamera": "allow",
"permissionmediadevices": "allowfull",
"permissionmicrophone": "allow",
"permissionnotifications": "allow"
}


let allSettings = {}
const freeText = [
"downloadpath",
Expand Down Expand Up @@ -1303,12 +1313,10 @@ const loadFromDisk = (firstRun = true) => {
sessionStorage.setItem("settings", JSON.stringify(allSettings))
}
if (isFile(joinPath(appData(), "erwicmode"))) {
set("containernewtab", "s:external")
set("containerstartuppage", "s:usematching")
set("permissioncamera", "allow")
set("permissionnotifications", "allow")
set("permissionmediadevices", "allowfull")
set("permissionmicrophone", "allow")
const erwicDefaults = JSON.parse(JSON.stringify(defaultErwicSettings))
Object.keys(erwicDefaults).forEach(t => {
set(t, erwicDefaults[t])
})
}
for (const conf of files) {
if (isFile(conf)) {
Expand Down Expand Up @@ -1611,6 +1619,13 @@ const listCurrentSettings = full => {
const settings = JSON.parse(JSON.stringify(allSettings))
if (!full) {
const defaults = JSON.parse(JSON.stringify(defaultSettings))
if (isFile(joinPath(appData(), "erwicmode"))) {
const erwicDefaults = JSON.parse(
JSON.stringify(defaultErwicSettings)
)
Object.assign(defaults, erwicDefaults)
}

Object.keys(settings).forEach(t => {
if (JSON.stringify(settings[t]) === JSON.stringify(defaults[t])) {
delete settings[t]
Expand Down

0 comments on commit 69f7d57

Please sign in to comment.