This commit is contained in:
Jaco
2023-01-15 21:27:52 +02:00
committed by GitHub
parent 9b4845a6d4
commit 7fa98ef5a1
16 changed files with 853 additions and 719 deletions
+15 -2
View File
@@ -8,7 +8,7 @@ import store from 'store';
import { hasProcess, isUndefined } from '@polkadot/util';
import { CAMERA, CAMERA_DEFAULT, CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING, LOCKING_DEFAULT, NOTIFICATION_DEFAULT, PREFIX_DEFAULT, PREFIXES, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
import { CAMERA, CAMERA_DEFAULT, CRYPTOS, CRYPTOS_ETH, CRYPTOS_LEDGER, ENDPOINT_DEFAULT, ENDPOINTS, ICON_DEFAULT, ICONS, LANGUAGE_DEFAULT, LEDGER_CONN, LEDGER_CONN_DEFAULT, LOCKING, LOCKING_DEFAULT, NOTIFICATION_DEFAULT, PREFIX_DEFAULT, PREFIXES, STORAGE, STORAGE_DEFAULT, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
type ChangeCallback = (settings: SettingsStruct) => void;
type OnTypes = 'change';
@@ -41,6 +41,8 @@ export class Settings implements SettingsStruct {
#prefix: number;
#storage: string;
#uiMode: string;
#uiTheme: string;
@@ -60,10 +62,11 @@ export class Settings implements SettingsStruct {
this.#i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
this.#icon = settings.icon || ICON_DEFAULT;
this.#locking = settings.locking || LOCKING_DEFAULT;
this.#notification = settings.notification || NOTIFICATION_DEFAULT;
this.#prefix = isUndefined(settings.prefix) ? PREFIX_DEFAULT : settings.prefix;
this.#storage = withDefault(STORAGE, settings.storage, STORAGE_DEFAULT);
this.#uiMode = settings.uiMode || UIMODE_DEFAULT;
this.#uiTheme = settings.uiTheme || UITHEME_DEFAULT;
this.#notification = settings.notification || NOTIFICATION_DEFAULT;
}
public get camera (): string {
@@ -102,6 +105,10 @@ export class Settings implements SettingsStruct {
return this.#prefix;
}
public get storage (): string {
return this.#storage;
}
public get uiMode (): string {
return this.#uiMode;
}
@@ -146,6 +153,10 @@ export class Settings implements SettingsStruct {
return PREFIXES;
}
public get availableStorage (): Option[] {
return STORAGE;
}
public get availableUIModes (): Option[] {
return UIMODES;
}
@@ -165,6 +176,7 @@ export class Settings implements SettingsStruct {
locking: this.#locking,
notification: this.#notification,
prefix: this.#prefix,
storage: this.#storage,
uiMode: this.#uiMode,
uiTheme: this.#uiTheme
};
@@ -180,6 +192,7 @@ export class Settings implements SettingsStruct {
this.#locking = settings.locking || this.#locking;
this.#notification = settings.notification || this.#notification;
this.#prefix = isUndefined(settings.prefix) ? this.#prefix : settings.prefix;
this.#storage = settings.storage || this.#storage;
this.#uiMode = settings.uiMode || this.#uiMode;
this.#uiTheme = settings.uiTheme || this.#uiTheme;
@@ -41,6 +41,21 @@ const LOCKING: Option[] = [
}
];
const STORAGE_DEFAULT = 'off';
const STORAGE: Option[] = [
{
info: 'on',
text: 'Allow local in-browser account storage',
value: 'on'
},
{
info: 'off',
text: 'Do not allow local in-browser account storage',
value: 'off'
}
];
export {
CAMERA_DEFAULT,
CAMERA,
@@ -60,6 +75,8 @@ export {
NOTIFICATION_DEFAULT,
PREFIX_DEFAULT,
PREFIXES,
STORAGE,
STORAGE_DEFAULT,
UIMODE_DEFAULT,
UIMODES,
UITHEME_DEFAULT,
+1
View File
@@ -18,6 +18,7 @@ export interface SettingsStruct {
locking: string;
notification: string;
prefix: number;
storage: string;
uiMode: string;
uiTheme: string;
}