Migrate players to automatic voice replies
Build and publish frontend / publish (push) Successful in 38s
Build and publish frontend / publish (push) Successful in 38s
This commit is contained in:
@@ -25,9 +25,22 @@
|
||||
return {command: aliases[command] || 'unknown'};
|
||||
}
|
||||
|
||||
function loadSettings(storage, key) {
|
||||
function loadSettings(storage, key, legacyKey) {
|
||||
try {
|
||||
const stored = JSON.parse(storage.getItem(key) || '{}');
|
||||
const current = storage.getItem(key);
|
||||
if (!current && legacyKey) {
|
||||
const legacy = JSON.parse(storage.getItem(legacyKey) || '{}');
|
||||
const migrated = {
|
||||
...DEFAULT_SETTINGS,
|
||||
rate: legacy.rate,
|
||||
voiceName: legacy.voiceName,
|
||||
speakerProfiles: legacy.speakerProfiles,
|
||||
soundSignals: legacy.soundSignals,
|
||||
};
|
||||
saveSettings(storage, key, migrated);
|
||||
return migrated;
|
||||
}
|
||||
const stored = JSON.parse(current || '{}');
|
||||
const settings = {...DEFAULT_SETTINGS, ...stored};
|
||||
if (!['screen-reader', 'game-voice', 'text-only'].includes(settings.mode)) settings.mode = DEFAULT_SETTINGS.mode;
|
||||
settings.rate = Math.min(2, Math.max(0.5, Number(settings.rate) || 1));
|
||||
|
||||
Reference in New Issue
Block a user