mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-20 02:59:26 +01:00
feat: Nicer design for abandonded DM rooms
This commit is contained in:
parent
8fd2d3918c
commit
754b919531
@ -2515,5 +2515,6 @@
|
|||||||
"sorryThatsNotPossible": "Sorry... that is not possible",
|
"sorryThatsNotPossible": "Sorry... that is not possible",
|
||||||
"deviceKeys": "Device keys:",
|
"deviceKeys": "Device keys:",
|
||||||
"letsStart": "Let's start",
|
"letsStart": "Let's start",
|
||||||
"enterInviteLinkOrMatrixId": "Enter invite link or Matrix ID..."
|
"enterInviteLinkOrMatrixId": "Enter invite link or Matrix ID...",
|
||||||
|
"reopenChat": "Reopen chat"
|
||||||
}
|
}
|
@ -133,6 +133,37 @@ class ChatController extends State<Chat> {
|
|||||||
|
|
||||||
bool showEmojiPicker = false;
|
bool showEmojiPicker = false;
|
||||||
|
|
||||||
|
bool get isLeftDMRoom {
|
||||||
|
final room = this.room;
|
||||||
|
final userId = room?.directChatMatrixID;
|
||||||
|
if (room == null || userId == null) return false;
|
||||||
|
return room.isDirectChat &&
|
||||||
|
room.unsafeGetUserFromMemoryOrFallback(userId).membership ==
|
||||||
|
Membership.leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
void recreateChat() async {
|
||||||
|
final room = this.room;
|
||||||
|
final userId = room?.directChatMatrixID;
|
||||||
|
if (room == null || userId == null) {
|
||||||
|
throw Exception(
|
||||||
|
'Try to recreate a room with is not a DM room. This should not be possible from the UI!');
|
||||||
|
}
|
||||||
|
final success = await showFutureLoadingDialog(
|
||||||
|
context: context,
|
||||||
|
future: () async {
|
||||||
|
final client = room.client;
|
||||||
|
final waitForSync = client.onSync.stream
|
||||||
|
.firstWhere((s) => s.rooms?.leave?.containsKey(room.id) ?? false);
|
||||||
|
await room.leave();
|
||||||
|
await waitForSync;
|
||||||
|
return await client.startDirectChat(userId);
|
||||||
|
});
|
||||||
|
final roomId = success.result;
|
||||||
|
if (roomId == null) return;
|
||||||
|
VRouter.of(context).toSegments(['rooms', roomId]);
|
||||||
|
}
|
||||||
|
|
||||||
EmojiPickerType emojiPickerType = EmojiPickerType.keyboard;
|
EmojiPickerType emojiPickerType = EmojiPickerType.keyboard;
|
||||||
|
|
||||||
void requestHistory() async {
|
void requestHistory() async {
|
||||||
|
@ -277,16 +277,47 @@ class ChatView extends StatelessWidget {
|
|||||||
Brightness.light
|
Brightness.light
|
||||||
? Colors.white
|
? Colors.white
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
child: Column(
|
child: controller.isLeftDMRoom
|
||||||
mainAxisSize: MainAxisSize.min,
|
? Row(
|
||||||
children: [
|
mainAxisAlignment:
|
||||||
const ConnectionStatusHeader(),
|
MainAxisAlignment.spaceEvenly,
|
||||||
ReactionsPicker(controller),
|
children: [
|
||||||
ReplyDisplay(controller),
|
TextButton.icon(
|
||||||
ChatInputRow(controller),
|
style: TextButton.styleFrom(
|
||||||
ChatEmojiPicker(controller),
|
foregroundColor:
|
||||||
],
|
Theme.of(context)
|
||||||
),
|
.colorScheme
|
||||||
|
.error,
|
||||||
|
),
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.archive_outlined,
|
||||||
|
),
|
||||||
|
onPressed: () {},
|
||||||
|
label: Text(
|
||||||
|
L10n.of(context)!.leave,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton.icon(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.chat_outlined,
|
||||||
|
),
|
||||||
|
onPressed:
|
||||||
|
controller.recreateChat,
|
||||||
|
label: Text(
|
||||||
|
L10n.of(context)!.reopenChat),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const ConnectionStatusHeader(),
|
||||||
|
ReactionsPicker(controller),
|
||||||
|
ReplyDisplay(controller),
|
||||||
|
ChatInputRow(controller),
|
||||||
|
ChatEmojiPicker(controller),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user