fix darkmode with color picker

This commit is contained in:
SethBurkart123
2023-10-20 06:48:02 +11:00
parent e0b4a29635
commit b1c9beb3d9
3 changed files with 7 additions and 33 deletions
+6 -2
View File
@@ -13,7 +13,12 @@ let DarkMode = null;
export function updateAllColors(storedSetting, newColor = null) { export function updateAllColors(storedSetting, newColor = null) {
// Determine the color to use // Determine the color to use
const selectedColor = newColor || storedSetting.selectedColor; const selectedColor = newColor || storedSetting.selectedColor;
DarkMode = storedSetting ? storedSetting.DarkMode : DarkMode;
DarkMode = (typeof storedSetting?.DarkMode === "boolean") ? storedSetting.DarkMode : DarkMode;
if (typeof storedSetting === "boolean") {
DarkMode = storedSetting;
}
// Common properties, always applied // Common properties, always applied
const commonProps = { const commonProps = {
@@ -24,7 +29,6 @@ export function updateAllColors(storedSetting, newColor = null) {
// Mode-based properties, applied if storedSetting is provided // Mode-based properties, applied if storedSetting is provided
let modeProps = {}; let modeProps = {};
console.log("Darkmode: ", DarkMode);
if (DarkMode !== null) { if (DarkMode !== null) {
modeProps = DarkMode ? { modeProps = DarkMode ? {
"--background-primary": "#232323", "--background-primary": "#232323",
-31
View File
@@ -1,31 +0,0 @@
export const openDB = async () => {
const request = indexedDB.open("MyDatabase", 1);
request.onupgradeneeded = async (event) => {
const db = event.target.result;
await db.createObjectStore("backgrounds", { keyPath: "id" });
};
return request;
};
export const writeData = async (type, data) => {
console.log("Reading Data");
const db = await openDB();
console.log("Opened DB");
const tx = db.transaction("backgrounds", "readwrite");
const store = tx.objectStore("backgrounds");
const request = await store.put({ id: "customBackground", type, data });
console.log("Data written successfully");
return request.result;
};
export const readData = async () => {
const db = await openDB();
const tx = db.transaction("backgrounds", "readonly");
const store = tx.objectStore("backgrounds");
return store.get("customBackground");
};
+1
View File
@@ -32,6 +32,7 @@ export default class StorageListener {
if (changes.DarkMode) { if (changes.DarkMode) {
this.darkMode = changes.DarkMode.newValue; this.darkMode = changes.DarkMode.newValue;
console.log(this.darkMode);
} }
if (changes?.customshortcuts?.newValue) { if (changes?.customshortcuts?.newValue) {