stickers replace composer, instead of sending immediately

Fixes #153
This commit is contained in:
Henry Hiles 2026-11-01 12:39:14 -05:00
commit 7baf56adef
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 252 additions and 153 deletions

View file

@ -178,25 +178,8 @@ class ClientController extends AsyncNotifier<int> {
Future<Event> sendMessage(SendMessageRequest request) async =>
Event.fromJson(await _sendCommand("send_message", request.toJson()));
Future<Event> sendEvent(SendEventRequest request) async {
final json = request.toJson();
final content = request.content.toJson();
return .fromJson(
await _sendCommand("send_event", {
...json,
"content": {
...content,
if (request.relatesTo != null)
"m.relates_to": {
...((content["m.relates_to"] as Map<String, dynamic>?) ?? {}),
"event_id": request.relatesTo,
"rel_type": request.relationType,
},
},
}),
);
}
Future<Event> sendEvent(SendEventRequest request) async =>
Event.fromJson(await _sendCommand("send_event", request.toJson()));
Future<String?> setState(SetStateRequest request) async =>
await _sendCommand("set_state", request.toJson());

View file

@ -340,7 +340,21 @@ class RoomChatController(final ChatParams info)
);
}
Future<void> sendSticker(String shortcode, PackImage image) async {
/// Sends [image] as a sticker, as a reply to [repliedEventRowId] if set.
Future<void> sendSticker(
String shortcode,
PackImage image, {
bool shouldMention = true,
int? repliedEventRowId,
}) async {
final repliedEvent = repliedEventRowId == null
? null
: ref.read(
RoomsController.provider.select(
(rooms) => rooms[info.roomId]?.events[repliedEventRowId],
),
);
final event = await ref
.read(ClientController.provider.notifier)
.sendEvent(
@ -352,6 +366,12 @@ class RoomChatController(final ChatParams info)
info: image.info ?? const .new(),
url: image.url,
),
mentions: Mentions(
userIds: [
if (shouldMention && repliedEvent != null) repliedEvent.sender,
].toIList(),
),
replyTo: repliedEvent?.eventId,
),
);