add set default if storage empty

This commit is contained in:
pakintada@gmail.com 2024-02-08 13:18:03 +07:00
parent 9ccea7f635
commit abfd27949f
2 changed files with 16 additions and 3 deletions

View file

@ -16,9 +16,19 @@ export class AppComponent implements OnInit {
// lang
Lang.initLanguageSwitcher();
// set default country and filename
await AsyncStorage.setItem('currentRecipeCountry', 'Thailand');
await AsyncStorage.setItem('currentFile', 'default');
// set default country and filename if empty
let currentCountry = await AsyncStorage.getItem('currentRecipeCountry');
let currentFile = await AsyncStorage.getItem('currentRecipeFile');
if (!currentCountry) {
await AsyncStorage.setItem('currentRecipeCountry', 'Thailand');
}
if (!currentFile) {
await AsyncStorage.setItem('currentRecipeFile', 'default');
}
}
}