From f6ab1e0d6d072a230edbd92c60a5d7e371cfb83b Mon Sep 17 00:00:00 2001 From: Sorunome Date: Sun, 4 Oct 2020 20:09:46 +0200 Subject: [PATCH] fix: Make theme loading work properly --- CHANGELOG.md | 2 ++ lib/components/theme_switcher.dart | 25 +++---------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4d83a6b..4a7c4996 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features - Add ability to enable / disable emotes globally - Add ability to manage emote packs with different state keys +### Fixes +- Fix amoled / theme settings not always saving properly # Version 0.19.0 - 2020-09-21 ### Features diff --git a/lib/components/theme_switcher.dart b/lib/components/theme_switcher.dart index 300bf72e..f5ddadfd 100644 --- a/lib/components/theme_switcher.dart +++ b/lib/components/theme_switcher.dart @@ -176,8 +176,9 @@ class ThemeSwitcherWidgetState extends State { Future loadSelection(MatrixState matrix) async { String item = await matrix.store.getItem('theme') ?? 'light'; - selectedTheme = - Themes.values.firstWhere((e) => e.toString() == 'Themes.' + item); + selectedTheme = Themes.values.firstWhere( + (e) => e.toString() == 'Themes.' + item, + orElse: () => Themes.system); amoledEnabled = (await matrix.store.getItem('amoled_enabled') ?? 'false') .toLowerCase() == @@ -238,26 +239,6 @@ class ThemeSwitcherWidgetState extends State { void setup() async { final matrix = Matrix.of(context); await loadSelection(matrix); - - if (selectedTheme == null) { - switchTheme(matrix, Themes.light, false); - } else { - switch (selectedTheme) { - case Themes.light: - switchTheme(matrix, Themes.light, false); - break; - case Themes.dark: - if (amoledEnabled) { - switchTheme(matrix, Themes.dark, true); - } else { - switchTheme(matrix, Themes.dark, false); - } - break; - case Themes.system: - switchTheme(matrix, Themes.system, false); - break; - } - } } @override