AniwatchPlus/src/javascript/configuration/configuration.js

44 lines
No EOL
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { getGlobalStorageProvider } from "../browserApi/storageProvider";
import { assigned } from "../utils/helpers";
// website
export const SETTINGS_websiteDisplayQuickSearch = 'websiteDisplayQuickSearch';
export const SETTINGS_websiteShowNotificationsCountInTab = 'websiteShowNotificationsCountInTab';
export const SETTINGS_websiteHideUnusedTabs = 'websiteHideUnusedTabs';
export const SETTINGS_websiteOptimizeListAppearance = 'websiteOptimizeListAppearance';
// anime
export const SETTINGS_animeLanguageDisplay = 'animeLanguageDisplay';
// requests
export const SETTINGS_requestBeautifyPage = 'requestBeautifyPage';
// player
export const SETTINGS_playerAutoplayAfterScreenshot = 'playerAutoplayAfterScreenshot';
// w2g
export const SETTINGS_w2gDisplayCharacterCounter = 'w2gDisplayCharacterCounter';
class Configuration {
constructor() {
this.settingsCache = new Map();
}
getProperty(key, callback) {
if (this.settingsCache.has(key)) {
callback(this.settingsCache.get(key));
}
else {
// OOOPS // currently all settings are default true. This isn´t a problem but there should be much better soloutions after migration to typescript....
let value = getGlobalStorageProvider().getData(key, true, value => {
this.settingsCache.set(key, value);
callback(value);
});
}
}
}
let __globalConfig = undefined;
export function getGlobalConfiguration() {
if (!assigned(__globalConfig)) {
__globalConfig = new Configuration();
}
return __globalConfig;
}