keep message drafts on room switches

this is for you courge
This commit is contained in:
Henry Hiles 2026-11-05 20:44:13 -05:00
commit e899bb3929
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -404,7 +404,10 @@ class RoomChatController(final ChatParams info)
roomId: info.roomId,
threadRoot: info.threadRoot,
);
final attachmentProvider = AttachmentController.provider(composer);
final attachmentProvider = AttachmentController.provider((
composer: composer,
editingRowId: relationType == .edit ? relatedEventRowId : null,
));
final attachment = ref.read(attachmentProvider)?.$2;
ref.invalidate(attachmentProvider);
@ -418,11 +421,13 @@ class RoomChatController(final ChatParams info)
? latestContent
: null);
// Replaces each formatted tag, like "@id#name#", with its ID
// Replaces each formatted tag, like ":id#name#", with its ID
final taggedMessage = tags.fold(
text,
(message, tag) => message.replaceAllMapped(
RegExp(r"@+(" + RegExp.escape(tag.id) + r")(#[^#]*#)?"),
RegExp(
"${RegExp.escape(tag.triggerCharacter)}(${RegExp.escape(tag.id)})(#[^#]*#)?",
),
(match) => match.group(1)!,
),
);