Skip to content

Commit

Permalink
Preload settings/theme in Settings window
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Aug 30, 2022
1 parent 006625b commit 5aa2adb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -2559,7 +2559,9 @@ function createSettings() {
webSecurity: false,
additionalArguments: ["jsVars" + Buffer.from(JSON.stringify({
appName: app.name,
appVersion: app.getVersion()
appVersion: app.getVersion(),
settings,
lastTheme
})).toString('base64')]
}
});
Expand Down
11 changes: 7 additions & 4 deletions src/settings-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ ipc.on('localization-updated', (event, localization) => {
}))
})

// User personalization settings recieved
ipc.on('theme-settings', (event, theme) => {
const processTheme = (event, theme) => {
try {
window.document.body.dataset["systemTheme"] = (theme.SystemUsesLightTheme == 0 ? "dark" : "light")
window.document.body.dataset["transparent"] = (theme.EnableTransparency == 0 || theme.UseAcrylic == 0 ? "false" : "true")
Expand All @@ -185,7 +184,10 @@ ipc.on('theme-settings', (event, theme) => {
window.document.body.dataset["acrylic"] = false
window.document.body.dataset["coloredTaskbar"] = "false"
}
})
}

// User personalization settings recieved
ipc.on('theme-settings', processTheme)

ipc.on('mica-wallpaper', (event, wallpaper) => {
const mica = document.querySelector("#mica .displays")
Expand All @@ -202,6 +204,7 @@ ipc.on('mica-wallpaper', (event, wallpaper) => {

// Request startup data
window.addEventListener("DOMContentLoaded", () => {
processTheme(undefined, getArgumentVars().lastTheme)
requestSettings()
requestMonitors()
requestAccent()
Expand All @@ -225,7 +228,7 @@ window.openURL = openURL
window.allMonitors = []
window.lastUpdate = Date.now()
window.showPanel = false
window.settings = {}
window.settings = getArgumentVars().settings
window.thisWindow = browser
window.accent = "cyan"

Expand Down

0 comments on commit 5aa2adb

Please sign in to comment.