Merge pull request #2672 from krille-chan/krille/multiple-fixes
chore: Add reset button for config viewer
This commit is contained in:
commit
d2cb802436
4 changed files with 26 additions and 7 deletions
|
|
@ -75,6 +75,11 @@ enum AppSettings<T> {
|
||||||
static SharedPreferences get store => _store!;
|
static SharedPreferences get store => _store!;
|
||||||
static SharedPreferences? _store;
|
static SharedPreferences? _store;
|
||||||
|
|
||||||
|
static Future<void> reset({bool loadWebConfigFile = true}) async {
|
||||||
|
await AppSettings._store!.clear();
|
||||||
|
await init(loadWebConfigFile: loadWebConfigFile);
|
||||||
|
}
|
||||||
|
|
||||||
static Future<SharedPreferences> init({bool loadWebConfigFile = true}) async {
|
static Future<SharedPreferences> init({bool loadWebConfigFile = true}) async {
|
||||||
if (AppSettings._store != null) return AppSettings.store;
|
if (AppSettings._store != null) return AppSettings.store;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2781,5 +2781,6 @@
|
||||||
"@mute": {
|
"@mute": {
|
||||||
"description": "This should be a very short string because there is not much space in the button!"
|
"description": "This should be a very short string because there is not much space in the button!"
|
||||||
},
|
},
|
||||||
"createNewChat": "Create new chat"
|
"createNewChat": "Create new chat",
|
||||||
|
"reset": "Reset"
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +48,11 @@ class _ConfigViewerState extends State<ConfigViewer> {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _reset() async {
|
||||||
|
await AppSettings.reset();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
@ -55,8 +60,12 @@ class _ConfigViewerState extends State<ConfigViewer> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(L10n.of(context).advancedConfigurations),
|
title: Text(L10n.of(context).advancedConfigurations),
|
||||||
leading: BackButton(onPressed: () => context.go('/')),
|
leading: BackButton(onPressed: () => context.go('/')),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: _reset, child: Text(L10n.of(context).reset)),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
crossAxisAlignment: .stretch,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.all(16),
|
margin: const EdgeInsets.all(16),
|
||||||
|
|
@ -81,7 +90,13 @@ class _ConfigViewerState extends State<ConfigViewer> {
|
||||||
value = appSetting.value.toString();
|
value = appSetting.value.toString();
|
||||||
}
|
}
|
||||||
if (appSetting is AppSettings<bool>) {
|
if (appSetting is AppSettings<bool>) {
|
||||||
value = appSetting.value.toString();
|
return SwitchListTile.adaptive(
|
||||||
|
title: Text(appSetting.name),
|
||||||
|
subtitle: Text(value),
|
||||||
|
value: appSetting.value,
|
||||||
|
onChanged: (value) =>
|
||||||
|
_changeSetting(appSetting, store, (!value).toString()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (appSetting is AppSettings<double>) {
|
if (appSetting is AppSettings<double>) {
|
||||||
value = appSetting.value.toString();
|
value = appSetting.value.toString();
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
});
|
});
|
||||||
onLogoutSub[name] ??= c.onLoginStateChanged.stream
|
onLogoutSub[name] ??= c.onLoginStateChanged.stream
|
||||||
.where((state) => state == LoginState.loggedOut)
|
.where((state) => state == LoginState.loggedOut)
|
||||||
.listen((state) {
|
.listen((_) {
|
||||||
final loggedInWithMultipleClients = widget.clients.length > 1;
|
final loggedInWithMultipleClients = widget.clients.length > 1;
|
||||||
|
|
||||||
_cancelSubs(c.clientName);
|
_cancelSubs(c.clientName);
|
||||||
|
|
@ -272,11 +272,9 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
||||||
).showSnackBar(
|
).showSnackBar(
|
||||||
SnackBar(content: Text(L10n.of(context).oneClientLoggedOut)),
|
SnackBar(content: Text(L10n.of(context).oneClientLoggedOut)),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
if (state != LoginState.loggedIn) {
|
|
||||||
FluffyChatApp.router.go('/rooms');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
FluffyChatApp.router.go('/');
|
||||||
});
|
});
|
||||||
onUiaRequest[name] ??= c.onUiaRequest.stream.listen(uiaRequestHandler);
|
onUiaRequest[name] ??= c.onUiaRequest.stream.listen(uiaRequestHandler);
|
||||||
if (PlatformInfos.isWeb || PlatformInfos.isLinux) {
|
if (PlatformInfos.isWeb || PlatformInfos.isLinux) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue