fix: Styling and notification settings

This commit is contained in:
Christian Pauly 2022-09-06 20:21:11 +02:00
commit 5629f14d5a
7 changed files with 29 additions and 6 deletions

View file

@ -58,26 +58,33 @@ class SettingsNotifications extends StatefulWidget {
class SettingsNotificationsController extends State<SettingsNotifications> {
bool? getNotificationSetting(NotificationSettingsItem item) {
final pushRules = Matrix.of(context).client.globalPushRules;
// Until https://gitlab.com/famedly/company/frontend/famedlysdk/-/merge_requests/1124 is shipped
final pushRulesRaw = Matrix.of(context)
.client
.accountData['m.push_rules']
?.content
.tryGetMap<String, dynamic>('device');
if (pushRulesRaw == null) return null;
final pushRules = PushRuleSet.fromJson(pushRulesRaw);
switch (item.type) {
case PushRuleKind.content:
return pushRules!.content
return pushRules.content
?.singleWhereOrNull((r) => r.ruleId == item.key)
?.enabled;
case PushRuleKind.override:
return pushRules!.override
return pushRules.override
?.singleWhereOrNull((r) => r.ruleId == item.key)
?.enabled;
case PushRuleKind.room:
return pushRules!.room
return pushRules.room
?.singleWhereOrNull((r) => r.ruleId == item.key)
?.enabled;
case PushRuleKind.sender:
return pushRules!.sender
return pushRules.sender
?.singleWhereOrNull((r) => r.ruleId == item.key)
?.enabled;
case PushRuleKind.underride:
return pushRules!.underride
return pushRules.underride
?.singleWhereOrNull((r) => r.ruleId == item.key)
?.enabled;
}