feat: Add "Show related DMs in spaces" settings

This commit is contained in:
20kdc 2022-04-09 06:10:53 +00:00 committed by Krille Fear
parent 4b17b1651b
commit 7e751fa726
6 changed files with 20 additions and 1 deletions

View File

@ -2145,6 +2145,11 @@
"type": "text",
"placeholders": {}
},
"showDirectChatsInSpaces": "Show related Direct Chats in Spaces",
"@showDirectChatsInSpaces": {
"type": "text",
"placeholders": {}
},
"showPassword": "Show password",
"@showPassword": {
"type": "text",

View File

@ -36,6 +36,7 @@ abstract class AppConfig {
static bool renderHtml = true;
static bool hideRedactedEvents = false;
static bool hideUnknownEvents = true;
static bool showDirectChatsInSpaces = true;
static bool separateChatTypes = false;
static bool autoplayImages = true;
static bool sendOnEnter = false;

View File

@ -3,6 +3,8 @@ abstract class SettingKeys {
static const String renderHtml = 'chat.fluffy.renderHtml';
static const String hideRedactedEvents = 'chat.fluffy.hideRedactedEvents';
static const String hideUnknownEvents = 'chat.fluffy.hideUnknownEvents';
static const String showDirectChatsInSpaces =
'chat.fluffy.showDirectChatsInSpaces';
static const String separateChatTypes = 'chat.fluffy.separateChatTypes';
static const String chatColor = 'chat.fluffy.chat_color';
static const String sentry = 'sentry';

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/client_stories_extension.dart';
import '../../widgets/matrix.dart';
@ -162,7 +163,7 @@ class SpaceSpacesEntry extends SpacesEntry {
if (_roomInsideSpace(room, space)) {
return true;
}
if (true) {
if (AppConfig.showDirectChatsInSpaces) {
if (room.isDirectChat &&
room.summary.mHeroes != null &&
room.summary.mHeroes!.any((userId) {

View File

@ -77,6 +77,12 @@ class SettingsChatView extends StatelessWidget {
),
),
const Divider(height: 1),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.showDirectChatsInSpaces,
onChanged: (b) => AppConfig.showDirectChatsInSpaces = b,
storeKey: SettingKeys.showDirectChatsInSpaces,
defaultValue: AppConfig.showDirectChatsInSpaces,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.separateChatTypes,
onChanged: (b) => AppConfig.separateChatTypes = b,

View File

@ -480,6 +480,10 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
store
.getItemBool(SettingKeys.hideUnknownEvents, AppConfig.hideUnknownEvents)
.then((value) => AppConfig.hideUnknownEvents = value);
store
.getItemBool(SettingKeys.showDirectChatsInSpaces,
AppConfig.showDirectChatsInSpaces)
.then((value) => AppConfig.showDirectChatsInSpaces = value);
store
.getItemBool(SettingKeys.separateChatTypes, AppConfig.separateChatTypes)
.then((value) => AppConfig.separateChatTypes = value);