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", "type": "String",
"placeholders": {} "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": "Show status messages from other users",
"@presencesToggle": { "@presencesToggle": {
"type": "String", "type": "String",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,6 +50,23 @@ class SettingsSecurityView extends StatelessWidget {
} }
return Column( return Column(
children: [ 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( ListTile(
title: Text( title: Text(
L10n.of(context).privacy, L10n.of(context).privacy,