This commit is contained in:
Henry Hiles 2026-01-30 02:13:46 +01:00
commit c2214fcc44
No known key found for this signature in database
15 changed files with 186 additions and 89 deletions

View file

@ -8,6 +8,7 @@ part "paginate.g.dart";
abstract class Paginate with _$Paginate {
const factory Paginate({
required IList<Event> events,
required IList<Event> relatedEvents,
required bool hasMore,
}) = _Paginate;

View file

@ -0,0 +1,15 @@
import "package:freezed_annotation/freezed_annotation.dart";
part "get_room_state_request.freezed.dart";
part "get_room_state_request.g.dart";
@freezed
abstract class GetRoomStateRequest with _$GetRoomStateRequest {
const factory GetRoomStateRequest({
required String roomId,
required bool fetchMembers,
@Default(false) bool includeMembers,
}) = _GetRoomStateRequest;
factory GetRoomStateRequest.fromJson(Map<String, Object?> json) =>
_$GetRoomStateRequestFromJson(json);
}

View file

@ -6,6 +6,7 @@ part "paginate_request.g.dart";
abstract class PaginateRequest with _$PaginateRequest {
const factory PaginateRequest({
required String roomId,
required int? maxTimelineId,
@Default(20) int limit,
}) = _PaginateRequest;

View file

@ -9,8 +9,8 @@ abstract class SendMessageRequest with _$SendMessageRequest {
const factory SendMessageRequest({
required String roomId,
required String text,
@Default(Mentions()) @JsonKey(name: "m.mentions") Mentions mentions,
@JsonKey(name: "m.relates_to") Relation? relation,
@Default(Mentions()) @JsonKey(name: "mentions") Mentions mentions,
@JsonKey(name: "relates_to") Relation? relation,
}) = _SendMessageRequest;
factory SendMessageRequest.fromJson(Map<String, Object?> json) =>
@ -28,17 +28,16 @@ abstract class Mentions with _$Mentions {
_$MentionsFromJson(json);
}
@freezed
@Freezed(toJson: false)
abstract class Relation with _$Relation {
const Relation._(); // required for custom methods
const Relation._();
const factory Relation({
required String eventId,
required RelationType relationType,
}) = _Relation;
@override
Map<String, Object?> toJson() {
Map<String, dynamic> toJson() {
switch (relationType) {
case RelationType.reply:
return {
@ -50,6 +49,6 @@ abstract class Relation with _$Relation {
}
}
factory Relation.fromJson(Map<String, Object?> json) =>
factory Relation.fromJson(Map<String, dynamic> json) =>
_$RelationFromJson(json);
}

View file

@ -11,12 +11,13 @@ abstract class Room with _$Room {
const factory Room({
@JsonKey(name: "meta") RoomMetadata? metadata,
@Default(IList.empty()) IList<TimelineRowTuple> timeline,
required bool reset,
required IMap<String, IMap> state,
@Default(false) bool reset,
@Default(IMap.empty()) IMap<String, IMap<String, int>> state,
// required IMap<String, AccountData> accountData,
required IList<Event> events,
@Default(IList.empty()) IList<Event> events,
@Default(IMap.empty()) IMap<String, IList<ReadReceipt>> receipts,
required bool dismissNotifications,
@Default(false) bool dismissNotifications,
@Default(true) bool hasMore,
// required IList<Notification> notifications,
}) = _Room;