parent
51e3fe1007
commit
7baf56adef
2 changed files with 252 additions and 153 deletions
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue