refactor: Store and fix missing persistence of some values

This commit is contained in:
krille-chan 2023-11-01 18:00:10 +01:00
commit c9c2620ad4
No known key found for this signature in database
12 changed files with 120 additions and 165 deletions

View file

@ -17,7 +17,6 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
import 'package:fluffychat/pages/settings_security/settings_security.dart';
import 'package:fluffychat/utils/famedlysdk_store.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
@ -189,7 +188,7 @@ class ChatListController extends State<ChatList>
],
);
if (newServer == null) return;
Store().setItem(_serverStoreNamespace, newServer.single);
Matrix.of(context).store.setString(_serverStoreNamespace, newServer.single);
setState(() {
searchServer = newServer.single;
});
@ -382,7 +381,8 @@ class ChatListController extends State<ChatList>
CallKeepManager().initialize();
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (mounted) {
searchServer = await Store().getItem(_serverStoreNamespace);
searchServer =
Matrix.of(context).store.getString(_serverStoreNamespace);
Matrix.of(context).backgroundPush?.setupPush();
}

View file

@ -30,13 +30,13 @@ class SettingsStyleController extends State<SettingsStyle> {
if (pickedFile == null) return;
await Matrix.of(context)
.store
.setItem(SettingKeys.wallpaper, pickedFile.path);
.setString(SettingKeys.wallpaper, pickedFile.path!);
setState(() {});
}
void deleteWallpaperAction() async {
Matrix.of(context).wallpaper = null;
await Matrix.of(context).store.deleteItem(SettingKeys.wallpaper);
await Matrix.of(context).store.remove(SettingKeys.wallpaper);
setState(() {});
}
@ -76,7 +76,7 @@ class SettingsStyleController extends State<SettingsStyle> {
void changeFontSizeFactor(double d) {
setState(() => AppConfig.fontSizeFactor = d);
Matrix.of(context).store.setItem(
Matrix.of(context).store.setString(
SettingKeys.fontSizeFactor,
AppConfig.fontSizeFactor.toString(),
);