remove console logging

This commit is contained in:
SethBurkart123
2023-11-05 11:39:59 +11:00
parent 95b8dd6cae
commit 37056e27e4
3 changed files with 5 additions and 20 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
"sourceType": "module" // add this line to allow 'import' and 'export' statements "sourceType": "module" // add this line to allow 'import' and 'export' statements
}, },
"rules": { "rules": {
"indent": ["warning", 2], "indent": ["error", 2],
"quotes": ["error", "double"], "quotes": ["error", "double"],
"semi": ["error", "always"] "semi": ["error", "always"]
} }
@@ -58,7 +58,6 @@ export default function BackgroundSelector({ selectedType, setSelectedType, isEd
if (!alreadyExists) { if (!alreadyExists) {
setDownloadProgress(prev => ({ ...prev, [bg.id]: 0 })); setDownloadProgress(prev => ({ ...prev, [bg.id]: 0 }));
const downloadedBg = await downloadPresetBackground(bg, progress => { const downloadedBg = await downloadPresetBackground(bg, progress => {
console.log(`${bg}, ${progress}`);
setDownloadProgress(prev => ({ ...prev, [bg.id]: progress })); setDownloadProgress(prev => ({ ...prev, [bg.id]: progress }));
}); });
setDownloadProgress(prev => { setDownloadProgress(prev => {
+4 -18
View File
@@ -1,6 +1,5 @@
import localforage from "localforage"; import localforage from "localforage";
let currentThemeStyle = null;
let currentThemeClass = ""; let currentThemeClass = "";
// Utility function to fetch and parse JSON // Utility function to fetch and parse JSON
@@ -80,7 +79,6 @@ const applyTheme = async (themeName) => {
export const listThemes = async () => { export const listThemes = async () => {
const themes = await localforage.keys(); const themes = await localforage.keys();
console.log("Themes in IndexedDB:", themes);
return { return {
themes: themes.filter((key) => key.startsWith("css_")).map((key) => key.replace("css_", "")), themes: themes.filter((key) => key.startsWith("css_")).map((key) => key.replace("css_", "")),
selectedTheme: await localforage.getItem("selectedTheme") selectedTheme: await localforage.getItem("selectedTheme")
@@ -88,15 +86,12 @@ export const listThemes = async () => {
}; };
export const downloadTheme = async (themeName, themeUrl) => { export const downloadTheme = async (themeName, themeUrl) => {
console.log(`Fetching theme ${themeName} from ${themeUrl}...`);
const themeData = await fetchThemeJSON(themeUrl); const themeData = await fetchThemeJSON(themeUrl);
await saveToIndexedDB(themeData, themeName); await saveToIndexedDB(themeData, themeName);
console.log(`Theme ${themeName} saved to IndexedDB`);
await setTheme(themeName, themeUrl); await setTheme(themeName, themeUrl);
}; };
export const deleteTheme = async (themeName) => { export const deleteTheme = async (themeName) => {
console.log(`Deleting theme ${themeName}...`);
const currentTheme = await localforage.getItem("selectedTheme"); const currentTheme = await localforage.getItem("selectedTheme");
if (currentTheme === themeName) { if (currentTheme === themeName) {
await disableTheme(); await disableTheme();
@@ -105,8 +100,7 @@ export const deleteTheme = async (themeName) => {
await Promise.all( await Promise.all(
(await localforage.keys()).filter((key) => key.startsWith(`images_${themeName}`)).map((key) => localforage.removeItem(key)) (await localforage.keys()).filter((key) => key.startsWith(`images_${themeName}`)).map((key) => localforage.removeItem(key))
); );
console.log(`Theme ${themeName} deleted.`); };
}
export const setTheme = async (themeName, themeUrl) => { export const setTheme = async (themeName, themeUrl) => {
if (!(await themeExistsInDB(themeName))) { if (!(await themeExistsInDB(themeName))) {
@@ -120,32 +114,26 @@ export const setTheme = async (themeName, themeUrl) => {
}; };
export const enableCurrentTheme = async () => { export const enableCurrentTheme = async () => {
console.log("Enabling current theme...");
const currentTheme = await localforage.getItem("selectedTheme"); const currentTheme = await localforage.getItem("selectedTheme");
if (currentTheme) { if (currentTheme) {
console.log(`Enabling current theme: ${currentTheme}`);
await applyTheme(currentTheme).catch((error) => { await applyTheme(currentTheme).catch((error) => {
console.error(`Failed to apply current theme: ${error}`); console.error(`Failed to apply current theme: ${error}`);
}); });
} else {
console.log("No current theme set in localforage.");
} }
}; };
export const disableTheme = async () => { export const disableTheme = async () => {
// Remove current theme's style if it exists // Remove current theme's style if it exists
if (currentThemeStyle) { if (window.currentThemeStyle) {
document.head.removeChild(currentThemeStyle); document.head.removeChild(window.currentThemeStyle);
currentThemeStyle = null; window.currentThemeStyle = null;
console.log("Current theme's style removed.");
} }
// Remove current theme's class if it exists // Remove current theme's class if it exists
if (currentThemeClass) { if (currentThemeClass) {
document.body.classList.remove(currentThemeClass); document.body.classList.remove(currentThemeClass);
currentThemeClass = ""; currentThemeClass = "";
console.log("Current theme's class removed.");
} }
// Remove any applied image URLs from the root element // Remove any applied image URLs from the root element
@@ -157,10 +145,8 @@ export const disableTheme = async () => {
document.documentElement.style.removeProperty(cssVar); document.documentElement.style.removeProperty(cssVar);
}); });
} }
console.log("Current theme's images removed.");
} }
// Clear the selected theme from localforage // Clear the selected theme from localforage
localforage.removeItem("selectedTheme"); localforage.removeItem("selectedTheme");
console.log("Current theme disabled.");
}; };