forked from Nexus/nexus
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
952bda6985 |
|||
|
4d00631fed |
5 changed files with 33 additions and 13 deletions
|
|
@ -170,8 +170,24 @@ 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 =>
|
||||
Event.fromJson(await _sendCommand("send_event", request.toJson()));
|
||||
Future<Event> sendEvent(SendEventRequest request) async {
|
||||
final json = request.toJson();
|
||||
final content = request.content.toJson();
|
||||
|
||||
return Event.fromJson(
|
||||
await _sendCommand("send_event", {
|
||||
...json,
|
||||
"content": {
|
||||
...content,
|
||||
"m.relates_to": {
|
||||
...((content["m.relates_to"] as Map<String, dynamic>?) ?? {}),
|
||||
"event_id": request.relatesTo,
|
||||
"rel_type": request.relationType,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String?> setState(SetStateRequest request) async =>
|
||||
await _sendCommand("set_state", request.toJson());
|
||||
|
|
|
|||
|
|
@ -205,15 +205,11 @@ class RoomChatController extends AsyncNotifier<IList<Event>?> {
|
|||
.new(
|
||||
roomId: roomId,
|
||||
type: EventType.reaction.type,
|
||||
content: {
|
||||
"m.relates_to": {
|
||||
"event_id": event.eventId,
|
||||
"rel_type": "m.annotation",
|
||||
"key": reaction,
|
||||
},
|
||||
},
|
||||
content: ReactionContent(key: reaction),
|
||||
synchronous: true,
|
||||
disableEncryption: true,
|
||||
relatesTo: event.eventId,
|
||||
relationType: "m.annotation",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import "package:nexus/models/content/content.dart";
|
|||
part "reaction.freezed.dart";
|
||||
part "reaction.g.dart";
|
||||
|
||||
@freezed
|
||||
@Freezed(toJson: false)
|
||||
abstract class ReactionContent extends Content with _$ReactionContent {
|
||||
ReactionContent._();
|
||||
static String? keyJsonFromJson(Map<dynamic, dynamic> json, String key) =>
|
||||
|
|
@ -13,6 +13,11 @@ abstract class ReactionContent extends Content with _$ReactionContent {
|
|||
@JsonKey(readValue: ReactionContent.keyJsonFromJson) String? key,
|
||||
}) = _ReactionContent;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => {
|
||||
"m.relates_to": {"key": key},
|
||||
};
|
||||
|
||||
factory ReactionContent.fromJson(Map<String, Object?> json) =>
|
||||
_$ReactionContentFromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/content/content.dart";
|
||||
part "send_event_request.freezed.dart";
|
||||
part "send_event_request.g.dart";
|
||||
|
||||
|
|
@ -7,7 +8,9 @@ abstract class SendEventRequest with _$SendEventRequest {
|
|||
const factory SendEventRequest({
|
||||
required String roomId,
|
||||
required String type,
|
||||
required Map<String, dynamic> content,
|
||||
required Content content,
|
||||
String? relatesTo,
|
||||
String? relationType,
|
||||
@Default(false) bool synchronous,
|
||||
@Default(false) bool disableEncryption,
|
||||
}) = _SendEventRequest;
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ class MemberList extends HookConsumerWidget {
|
|||
if (member.content
|
||||
case MembershipContent content) {
|
||||
showModalBottomSheet(
|
||||
constraints: BoxConstraints.loose(
|
||||
Size(
|
||||
constraints: .loose(
|
||||
.new(
|
||||
500,
|
||||
(context.size?.height ?? 1000) - 80,
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue