Do not accept invites by clicking tile, also add option to hide avatars in invites

This commit is contained in:
OfficialDakari 2025-05-21 17:38:25 +05:00
parent e99be68eef
commit b94408c6a4
7 changed files with 96 additions and 34 deletions

View File

@ -2026,6 +2026,16 @@
"type": "String",
"placeholders": {}
},
"hideAvatarsInInvites": "Hide avatars in invites",
"@hideAvatarsInInvites": {
"type": "String",
"placeholders": {}
},
"hideAvatarsInInvitesDescription": "Do not show room avatars in invites",
"@hideAvatarsInInvitesDescription": {
"type": "String",
"placeholders": {}
},
"presencesToggle": "Show status messages from other users",
"@presencesToggle": {
"type": "String",

View File

@ -57,6 +57,7 @@ abstract class AppConfig {
static bool sendTypingNotifications = true;
static bool sendPublicReadReceipts = true;
static bool swipeRightToLeftToReply = true;
static bool hideAvatarsInInvites = true;
static bool? sendOnEnter;
static bool showPresences = true;
static bool experimentalVoip = false;

View File

@ -1,6 +1,7 @@
import 'package:shared_preferences/shared_preferences.dart';
abstract class SettingKeys {
static const String hideAvatarsInInvites = 'xyz.extera.next.hideAvatarsInInvites';
static const String pureBlack = 'xyz.extera.next.pureBlack';
static const String renderHtml = 'chat.fluffy.renderHtml';
static const String hideRedactedEvents = 'chat.fluffy.hideRedactedEvents';

View File

@ -111,21 +111,14 @@ class ChatListController extends State<ChatList>
_activeSpaceId = null;
});
void onChatTap(Room room) async {
if (room.membership == Membership.invite) {
final joinResult = await showFutureLoadingDialog(
context: context,
future: () async {
final waitForRoom = room.client.waitForRoomInSync(
room.id,
join: true,
);
await room.join();
await waitForRoom;
},
exceptionContext: ExceptionContext.joinRoom,
);
if (joinResult.error != null) return;
void onChatTap(
Room room, [
BuildContext? posContext,
Room? space,
]) async {
if (room.membership == Membership.invite && posContext != null) {
chatContextAction(room, posContext, space);
return;
}
if (room.membership == Membership.ban) {
@ -474,11 +467,13 @@ class ChatListController extends State<ChatList>
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Avatar(
mxContent: room.avatar,
size: Avatar.defaultSize / 2,
name: displayname,
),
if (!AppConfig.hideAvatarsInInvites ||
room.membership != Membership.invite)
Avatar(
mxContent: room.avatar,
size: Avatar.defaultSize / 2,
name: displayname,
),
const SizedBox(width: 12),
Text(
displayname,
@ -495,11 +490,13 @@ class ChatListController extends State<ChatList>
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Avatar(
mxContent: space.avatar,
size: Avatar.defaultSize / 2,
name: space.getLocalizedDisplayname(),
),
if (!AppConfig.hideAvatarsInInvites ||
room.membership != Membership.invite)
Avatar(
mxContent: space.avatar,
size: Avatar.defaultSize / 2,
name: space.getLocalizedDisplayname(),
),
const SizedBox(width: 12),
Expanded(
child: Text(
@ -580,22 +577,40 @@ class ChatListController extends State<ChatList>
],
if (room.membership == Membership.invite)
PopupMenuItem(
value: ChatContextAction.block,
value: ChatContextAction.join,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.block_outlined,
color: Theme.of(context).colorScheme.error,
Icons.check_circle_outline,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(width: 12),
Text(
L10n.of(context).block,
style: TextStyle(color: Theme.of(context).colorScheme.error),
L10n.of(context).accept,
style:
TextStyle(color: Theme.of(context).colorScheme.primary),
),
],
),
),
PopupMenuItem(
value: ChatContextAction.block,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.block_outlined,
color: Theme.of(context).colorScheme.error,
),
const SizedBox(width: 12),
Text(
L10n.of(context).block,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
],
),
),
PopupMenuItem(
value: ChatContextAction.leave,
child: Row(
@ -624,6 +639,21 @@ class ChatListController extends State<ChatList>
if (!mounted) return;
switch (action) {
case ChatContextAction.join:
final joinResult = await showFutureLoadingDialog(
context: context,
future: () async {
final waitForRoom = room.client.waitForRoomInSync(
room.id,
join: true,
);
await room.join();
await waitForRoom;
},
exceptionContext: ExceptionContext.joinRoom,
);
if (joinResult.error != null) return;
return;
case ChatContextAction.open:
onChatTap(room);
return;
@ -909,6 +939,7 @@ enum InviteActions {
}
enum ChatContextAction {
join,
open,
goToSpace,
favorite,

View File

@ -35,7 +35,7 @@ class ChatListViewBody extends StatelessWidget {
key: ValueKey(activeSpace),
spaceId: activeSpace,
onBack: controller.clearActiveSpace,
onChatTab: (room) => controller.onChatTap(room),
onChatTab: (room) => controller.onChatTap(room, context),
onChatContext: (room, context) =>
controller.chatContextAction(room, context),
activeChat: controller.activeChat,
@ -259,7 +259,7 @@ class ChatListViewBody extends StatelessWidget {
space: space,
key: Key('chat_list_item_${room.id}'),
filter: filter,
onTap: () => controller.onChatTap(room),
onTap: () => controller.onChatTap(room, context, space),
onLongPress: (context) =>
controller.chatContextAction(room, context, space),
activeChat: controller.activeChat == room.id,

View File

@ -114,7 +114,9 @@ class ChatListItem extends StatelessWidget {
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
scale: hovered ? 1.1 : 1.0,
child: SizedBox(
child:
(!AppConfig.hideAvatarsInInvites || room.membership != Membership.invite)
? SizedBox(
width: Avatar.defaultSize,
height: Avatar.defaultSize,
child: Stack(
@ -191,7 +193,7 @@ class ChatListItem extends StatelessWidget {
),
],
),
),
) : null,
),
),
title: Row(

View File

@ -50,6 +50,23 @@ class SettingsSecurityView extends StatelessWidget {
}
return Column(
children: [
ListTile(
title: Text(
L10n.of(context).security,
style: TextStyle(
color: theme.colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).hideAvatarsInInvites,
subtitle:
L10n.of(context).hideAvatarsInInvitesDescription,
onChanged: (b) => AppConfig.hideAvatarsInInvites = b,
storeKey: SettingKeys.hideAvatarsInInvites,
defaultValue: AppConfig.hideAvatarsInInvites,
),
ListTile(
title: Text(
L10n.of(context).privacy,