forked from Henry-Hiles/nexus
wip
This commit is contained in:
parent
6afa169af9
commit
f51d773885
12 changed files with 182 additions and 156 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/epoch_date_time_converter.dart";
|
||||
part "event.freezed.dart";
|
||||
|
|
@ -14,10 +15,10 @@ abstract class Event with _$Event {
|
|||
required String type,
|
||||
String? stateKey,
|
||||
@EpochDateTimeConverter() required DateTime timestamp,
|
||||
required Map<String, dynamic> content,
|
||||
Map<String, dynamic>? decrypted,
|
||||
required IMap<String, dynamic> content,
|
||||
IMap<String, dynamic>? decrypted,
|
||||
String? decryptedType,
|
||||
@Default({}) Map<String, dynamic> unsigned,
|
||||
@Default(IMap.empty()) IMap<String, dynamic> unsigned,
|
||||
LocalContent? localContent,
|
||||
String? transactionId,
|
||||
String? redactedBy,
|
||||
|
|
@ -25,7 +26,7 @@ abstract class Event with _$Event {
|
|||
String? relatesType,
|
||||
String? decryptionError,
|
||||
String? sendError,
|
||||
@Default({}) Map<String, int> reactions,
|
||||
@Default(IMap.empty()) IMap<String, int> reactions,
|
||||
int? lastEditRowId,
|
||||
@UnreadTypeConverter() UnreadType? unreadType,
|
||||
}) = _Event;
|
||||
|
|
@ -57,6 +58,7 @@ class UnreadTypeConverter implements JsonConverter<UnreadType?, int?> {
|
|||
int? toJson(UnreadType? object) => object?.value;
|
||||
}
|
||||
|
||||
// I think this is correct but I'm not sure, its some type of bitmask.
|
||||
@immutable
|
||||
class UnreadType {
|
||||
final int value;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
part "lazy_load_summary.freezed.dart";
|
||||
part "lazy_load_summary.g.dart";
|
||||
|
|
@ -5,7 +6,7 @@ part "lazy_load_summary.g.dart";
|
|||
@freezed
|
||||
abstract class LazyLoadSummary with _$LazyLoadSummary {
|
||||
const factory LazyLoadSummary({
|
||||
required List<String>? heroes,
|
||||
required IList<String>? heroes,
|
||||
required int? joinedMemberCount,
|
||||
required int? invitedMemberCount,
|
||||
}) = _LazyLoadSummary;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/event.dart";
|
||||
import "package:nexus/models/read_receipt.dart";
|
||||
|
|
@ -9,14 +10,14 @@ part "room.g.dart";
|
|||
abstract class Room with _$Room {
|
||||
const factory Room({
|
||||
@JsonKey(name: "meta") RoomMetadata? metadata,
|
||||
@Default([]) List<TimelineRowTuple> timeline,
|
||||
@Default(IList.empty()) IList<TimelineRowTuple> timeline,
|
||||
required bool reset,
|
||||
required Map<String, Map> state,
|
||||
// required Map<String, AccountData> accountData,
|
||||
required List<Event> events,
|
||||
@Default({}) Map<String, List<ReadReceipt>> receipts,
|
||||
required IMap<String, IMap> state,
|
||||
// required IMap<String, AccountData> accountData,
|
||||
required IList<Event> events,
|
||||
@Default(IMap.empty()) IMap<String, IList<ReadReceipt>> receipts,
|
||||
required bool dismissNotifications,
|
||||
// required List<Notification> notifications,
|
||||
// required IList<Notification> notifications,
|
||||
}) = _Room;
|
||||
|
||||
factory Room.fromJson(Map<String, Object?> json) => _$RoomFromJson(json);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ part "room_metadata.g.dart";
|
|||
abstract class RoomMetadata with _$RoomMetadata {
|
||||
const factory RoomMetadata({
|
||||
@JsonKey(name: "room_id") required String id,
|
||||
|
||||
// required CreateEventContent creationContent,
|
||||
// required TombstoneEventContent tombstoneEventContent,
|
||||
String? name,
|
||||
Uri? avatar,
|
||||
String? dmUserId,
|
||||
String? topic,
|
||||
String? canonicalAlias,
|
||||
LazyLoadSummary? lazyLoadSummary,
|
||||
|
|
|
|||
15
lib/models/space.dart
Normal file
15
lib/models/space.dart
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import "package:flutter/widgets.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/room.dart";
|
||||
part "space.freezed.dart";
|
||||
|
||||
@freezed
|
||||
abstract class Space with _$Space {
|
||||
const factory Space({
|
||||
required String id,
|
||||
required String title,
|
||||
IconData? icon,
|
||||
Room? room,
|
||||
required List<Room> children,
|
||||
}) = _Space;
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/room.dart";
|
||||
part "sync_data.freezed.dart";
|
||||
|
|
@ -7,12 +8,12 @@ part "sync_data.g.dart";
|
|||
abstract class SyncData with _$SyncData {
|
||||
const factory SyncData({
|
||||
@Default(false) bool clearState,
|
||||
// required Map<String, AccountData> accountData,
|
||||
@Default({}) Map<String, Room> rooms,
|
||||
@Default([]) List<String> leftRooms,
|
||||
// required List<InvitedRoom> invitedRooms,
|
||||
// required List<SpaceEdge> spaceEdges,
|
||||
@Default([]) List<String> topLevelSpaces,
|
||||
// required IMap<String, AccountData> accountData,
|
||||
@Default(IMap.empty()) IMap<String, Room> rooms,
|
||||
@Default(ISet.empty()) ISet<String> leftRooms,
|
||||
// required IList<InvitedRoom> invitedRooms,
|
||||
// required IList<SpaceEdge> spaceEdges,
|
||||
@Default(IList.empty()) IList<String> topLevelSpaces,
|
||||
}) = _SyncData;
|
||||
|
||||
factory SyncData.fromJson(Map<String, Object?> json) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue