forked from Nexus/nexus
Support for pinned messages (#49)
The first draft to support pinned messages. Fixes #39. Co-authored-by: Henry-Hiles <henry@henryhiles.com> Reviewed-on: Nexus/nexus#49
This commit is contained in:
parent
71a4274ff2
commit
818e582ddd
15 changed files with 570 additions and 279 deletions
|
|
@ -10,7 +10,7 @@ part "message.g.dart";
|
|||
@Freezed(unionKey: "msgtype", fallbackUnion: "default")
|
||||
abstract class MessageContent extends Content with _$MessageContent {
|
||||
MessageContent._();
|
||||
factory MessageContent({required String body}) = UnknownMessageContent;
|
||||
factory MessageContent({String? body}) = UnknownMessageContent;
|
||||
|
||||
@FreezedUnionValue("m.text")
|
||||
factory MessageContent.text({
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ part "pinned_events.g.dart";
|
|||
@freezed
|
||||
abstract class PinnedEventsContent extends Content with _$PinnedEventsContent {
|
||||
PinnedEventsContent._();
|
||||
factory PinnedEventsContent({@Default(IList.empty()) IList<String> pinned}) =
|
||||
_PinnedEventsContent;
|
||||
factory PinnedEventsContent({
|
||||
@Default(IList.empty()) @JsonKey(name: "pinned") IList<String> pinnedEvents,
|
||||
}) = _PinnedEventsContent;
|
||||
|
||||
factory PinnedEventsContent.fromJson(Map<String, Object?> json) =>
|
||||
_$PinnedEventsContentFromJson(json);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
23
lib/models/requests/set_state_request.dart
Normal file
23
lib/models/requests/set_state_request.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/content/content.dart";
|
||||
import "package:nexus/models/ms_duration.dart";
|
||||
part "set_state_request.freezed.dart";
|
||||
part "set_state_request.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class SetStateRequest with _$SetStateRequest {
|
||||
const factory SetStateRequest({
|
||||
required String roomId,
|
||||
required String type,
|
||||
required String stateKey,
|
||||
required Content content,
|
||||
|
||||
@JsonKey(name: "delay_ms", includeIfNull: false)
|
||||
@MSDuration()
|
||||
@Default(null)
|
||||
Duration? delay,
|
||||
}) = _SetStateRequest;
|
||||
|
||||
factory SetStateRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$SetStateRequestFromJson(json);
|
||||
}
|
||||
Loading…
Reference in a new issue