mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-21 20:46:14 -04:00
wip
This commit is contained in:
parent
1ba55bf2a6
commit
4d7d57f17f
15 changed files with 165 additions and 120 deletions
|
@ -1,5 +1,8 @@
|
|||
// Settings
|
||||
|
||||
import {toast} from "./toast";
|
||||
import {t} from "./i18n/i18n";
|
||||
|
||||
let cachedSettings: { [key: string]: unknown } = {};
|
||||
|
||||
try {
|
||||
|
@ -24,6 +27,7 @@ export function setSettingValue<T>(key: string, value: T) {
|
|||
needsSaving.add(key);
|
||||
cachedSettings[key] = value;
|
||||
}
|
||||
|
||||
export function commitSettingsChangesToLocalStorage() {
|
||||
try {
|
||||
for (let key of needsSaving) {
|
||||
|
@ -49,3 +53,19 @@ export function getCurrentMaxParticles() {
|
|||
export function cycleMaxCoins() {
|
||||
setSettingValue("max_coins", (getSettingValue("max_coins", 2) + 1) % 7);
|
||||
}
|
||||
|
||||
let asked=false
|
||||
export function askForPersistentStorage(){
|
||||
if(asked) return
|
||||
asked=true
|
||||
if (navigator.storage && navigator.storage.persist) {
|
||||
navigator.storage.persist().then((persistent) => {
|
||||
if (persistent) {
|
||||
toast(t('settings.storage_granted'))
|
||||
} else {
|
||||
toast(t('settings.storage_refused'))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue