parent
b3db9bea6f
commit
6af56ccb3e
17 changed files with 101 additions and 175 deletions
|
|
@ -212,7 +212,7 @@ dart scripts/generate.dart
|
||||||
Build generated files, and watch for new changes:
|
Build generated files, and watch for new changes:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
flutter pub run build_runner watch
|
flutter pub run build_runner watch --delete-conflicting-outputs
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the app:
|
Run the app:
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import "package:nexus/controllers/top_level_spaces_controller.dart";
|
||||||
import "package:nexus/helpers/extensions/gomuks_buffer.dart";
|
import "package:nexus/helpers/extensions/gomuks_buffer.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
import "package:nexus/models/client_state.dart";
|
import "package:nexus/models/client_state.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/paginate.dart";
|
import "package:nexus/models/paginate.dart";
|
||||||
import "package:nexus/models/requests/get_event_request.dart";
|
import "package:nexus/models/requests/get_event_request.dart";
|
||||||
import "package:nexus/models/requests/get_related_events_request.dart";
|
import "package:nexus/models/requests/get_related_events_request.dart";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/client_controller.dart";
|
import "package:nexus/controllers/client_controller.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/requests/get_event_request.dart";
|
import "package:nexus/models/requests/get_event_request.dart";
|
||||||
|
|
||||||
class EventController extends AsyncNotifier<Event?> {
|
class EventController extends AsyncNotifier<Event?> {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import "package:nexus/controllers/rooms_controller.dart";
|
||||||
import "package:nexus/controllers/selected_room_controller.dart";
|
import "package:nexus/controllers/selected_room_controller.dart";
|
||||||
import "package:nexus/models/configs/messages_config.dart";
|
import "package:nexus/models/configs/messages_config.dart";
|
||||||
import "package:nexus/models/configs/message_config.dart";
|
import "package:nexus/models/configs/message_config.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/requests/get_related_events_request.dart";
|
import "package:nexus/models/requests/get_related_events_request.dart";
|
||||||
import "package:nexus/models/requests/get_room_state_request.dart";
|
import "package:nexus/models/requests/get_room_state_request.dart";
|
||||||
import "package:nexus/models/requests/paginate_request.dart";
|
import "package:nexus/models/requests/paginate_request.dart";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import "package:collection/collection.dart";
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/client_state_controller.dart";
|
import "package:nexus/controllers/client_state_controller.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
|
||||||
import "package:nexus/models/room.dart";
|
import "package:nexus/models/room.dart";
|
||||||
|
|
||||||
class ViaController extends Notifier<String> {
|
class ViaController extends Notifier<String> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
import "package:freezed_annotation/freezed_annotation.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/room.dart";
|
import "package:nexus/models/room.dart";
|
||||||
part "message_config.freezed.dart";
|
part "message_config.freezed.dart";
|
||||||
part "message_config.g.dart";
|
part "message_config.g.dart";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
import "package:freezed_annotation/freezed_annotation.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/room.dart";
|
import "package:nexus/models/room.dart";
|
||||||
part "messages_config.freezed.dart";
|
part "messages_config.freezed.dart";
|
||||||
part "messages_config.g.dart";
|
part "messages_config.g.dart";
|
||||||
|
|
|
||||||
80
lib/models/event.dart
Normal file
80
lib/models/event.dart
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
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";
|
||||||
|
part "event.g.dart";
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class Event with _$Event {
|
||||||
|
const factory Event({
|
||||||
|
@JsonKey(name: "rowid") required int rowId,
|
||||||
|
@JsonKey(name: "timeline_rowid") required int timelineRowId,
|
||||||
|
required String roomId,
|
||||||
|
required String eventId,
|
||||||
|
required String sender,
|
||||||
|
required String type,
|
||||||
|
String? stateKey,
|
||||||
|
@EpochDateTimeConverter() required DateTime timestamp,
|
||||||
|
required IMap<String, dynamic> content,
|
||||||
|
IMap<String, dynamic>? decrypted,
|
||||||
|
String? decryptedType,
|
||||||
|
@Default(IMap.empty()) IMap<String, dynamic> unsigned,
|
||||||
|
LocalContent? localContent,
|
||||||
|
String? transactionId,
|
||||||
|
String? redactedBy,
|
||||||
|
String? relatesTo,
|
||||||
|
String? relationType,
|
||||||
|
String? decryptionError,
|
||||||
|
String? sendError,
|
||||||
|
@Default(IMap.empty()) IMap<String, int> reactions,
|
||||||
|
@JsonKey(name: "last_edit_rowid") int? lastEditRowId,
|
||||||
|
@UnreadTypeConverter() UnreadType? unreadType,
|
||||||
|
}) = _Event;
|
||||||
|
|
||||||
|
factory Event.fromJson(Map<String, Object?> json) => _$EventFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
abstract class LocalContent with _$LocalContent {
|
||||||
|
const factory LocalContent({
|
||||||
|
String? sanitizedHtml,
|
||||||
|
String? editSource,
|
||||||
|
bool? wasPlaintext,
|
||||||
|
bool? bigEmoji,
|
||||||
|
bool? hasMath,
|
||||||
|
bool? replyFallbackRemoved,
|
||||||
|
}) = _LocalContent;
|
||||||
|
|
||||||
|
factory LocalContent.fromJson(Map<String, Object?> json) =>
|
||||||
|
_$LocalContentFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnreadTypeConverter implements JsonConverter<UnreadType?, int?> {
|
||||||
|
const UnreadTypeConverter();
|
||||||
|
|
||||||
|
@override
|
||||||
|
UnreadType? fromJson(int? json) => json == null ? null : UnreadType(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
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;
|
||||||
|
|
||||||
|
const UnreadType(this.value);
|
||||||
|
|
||||||
|
static const none = UnreadType(0);
|
||||||
|
static const normal = UnreadType(1);
|
||||||
|
static const notify = UnreadType(2);
|
||||||
|
static const highlight = UnreadType(4);
|
||||||
|
static const sound = UnreadType(8);
|
||||||
|
|
||||||
|
bool get isNone => value == 0;
|
||||||
|
bool get isNormal => (value & 1) != 0;
|
||||||
|
bool get shouldNotify => (value & 2) != 0;
|
||||||
|
bool get isHighlighted => (value & 4) != 0;
|
||||||
|
bool get playsSound => (value & 8) != 0;
|
||||||
|
}
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
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";
|
|
||||||
import "package:nexus/models/event/local_content.dart";
|
|
||||||
import "package:nexus/models/event/unread_type.dart";
|
|
||||||
part "info.freezed.dart";
|
|
||||||
part "info.g.dart";
|
|
||||||
|
|
||||||
@Freezed(unionKey: "type")
|
|
||||||
abstract class EventInfo with _$EventInfo {
|
|
||||||
const factory EventInfo({
|
|
||||||
@JsonKey(name: "rowid") required int rowId,
|
|
||||||
@JsonKey(name: "timeline_rowid") required int timelineRowId,
|
|
||||||
required String type,
|
|
||||||
required String roomId,
|
|
||||||
required String eventinfoId,
|
|
||||||
required String sender,
|
|
||||||
String? stateKey,
|
|
||||||
@EpochDateTimeConverter() required DateTime timestamp,
|
|
||||||
@JsonKey(name: "content") required IMap<String, dynamic> rawContent,
|
|
||||||
IMap<String, dynamic>? decrypted,
|
|
||||||
String? decryptedType,
|
|
||||||
@Default(IMap.empty()) IMap<String, dynamic> unsigned,
|
|
||||||
LocalContent? localContent,
|
|
||||||
String? transactionId,
|
|
||||||
String? redactedBy,
|
|
||||||
String? relatesTo,
|
|
||||||
String? relationType,
|
|
||||||
String? decryptionError,
|
|
||||||
String? sendError,
|
|
||||||
@Default(IMap.empty()) IMap<String, int> reactions,
|
|
||||||
@JsonKey(name: "last_edit_rowid") int? lastEditRowId,
|
|
||||||
@UnreadTypeConverter() UnreadType? unreadType,
|
|
||||||
}) = _EventInfo;
|
|
||||||
|
|
||||||
factory EventInfo.fromJson(Map<String, Object?> json) =>
|
|
||||||
_$EventInfoFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
|
||||||
import "package:nexus/models/event/info.dart";
|
|
||||||
part "event.freezed.dart";
|
|
||||||
part "event.g.dart";
|
|
||||||
|
|
||||||
@Freezed(unionKey: "type")
|
|
||||||
abstract class Event with _$Event {
|
|
||||||
const factory Event({@JsonKey(flatten: true) required EventInfo info}) =
|
|
||||||
_GenericEvent;
|
|
||||||
|
|
||||||
@FreezedUnionValue("m.room.member")
|
|
||||||
const factory Event.membership({
|
|
||||||
@JsonKey(flatten: true) required EventInfo info,
|
|
||||||
required String content,
|
|
||||||
}) = _MemberEvent;
|
|
||||||
|
|
||||||
factory Event.fromJson(Map<String, Object?> json) => _$EventFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
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";
|
|
||||||
import "package:nexus/models/event/local_content.dart";
|
|
||||||
import "package:nexus/models/event/unread_type.dart";
|
|
||||||
part "info.freezed.dart";
|
|
||||||
part "info.g.dart";
|
|
||||||
|
|
||||||
@Freezed(unionKey: "type")
|
|
||||||
abstract class EventInfo with _$EventInfo {
|
|
||||||
const factory EventInfo({
|
|
||||||
@JsonKey(name: "rowid") required int rowId,
|
|
||||||
@JsonKey(name: "timeline_rowid") required int timelineRowId,
|
|
||||||
required String type,
|
|
||||||
required String roomId,
|
|
||||||
required String eventinfoId,
|
|
||||||
required String sender,
|
|
||||||
String? stateKey,
|
|
||||||
@EpochDateTimeConverter() required DateTime timestamp,
|
|
||||||
@JsonKey(name: "content") required IMap<String, dynamic> rawContent,
|
|
||||||
IMap<String, dynamic>? decrypted,
|
|
||||||
String? decryptedType,
|
|
||||||
@Default(IMap.empty()) IMap<String, dynamic> unsigned,
|
|
||||||
LocalContent? localContent,
|
|
||||||
String? transactionId,
|
|
||||||
String? redactedBy,
|
|
||||||
String? relatesTo,
|
|
||||||
String? relationType,
|
|
||||||
String? decryptionError,
|
|
||||||
String? sendError,
|
|
||||||
@Default(IMap.empty()) IMap<String, int> reactions,
|
|
||||||
@JsonKey(name: "last_edit_rowid") int? lastEditRowId,
|
|
||||||
@UnreadTypeConverter() UnreadType? unreadType,
|
|
||||||
}) = _EventInfo;
|
|
||||||
|
|
||||||
factory EventInfo.fromJson(Map<String, Object?> json) =>
|
|
||||||
_$EventInfoFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
|
||||||
part "local_content.g.dart";
|
|
||||||
part "local_content.freezed.dart";
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
abstract class LocalContent with _$LocalContent {
|
|
||||||
const factory LocalContent({
|
|
||||||
String? sanitizedHtml,
|
|
||||||
String? editSource,
|
|
||||||
bool? wasPlaintext,
|
|
||||||
bool? bigEmoji,
|
|
||||||
bool? hasMath,
|
|
||||||
bool? replyFallbackRemoved,
|
|
||||||
}) = _LocalContent;
|
|
||||||
|
|
||||||
factory LocalContent.fromJson(Map<String, Object?> json) =>
|
|
||||||
_$LocalContentFromJson(json);
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
|
||||||
|
|
||||||
class UnreadTypeConverter implements JsonConverter<UnreadType?, int?> {
|
|
||||||
const UnreadTypeConverter();
|
|
||||||
|
|
||||||
@override
|
|
||||||
UnreadType? fromJson(int? json) => json == null ? null : UnreadType(json);
|
|
||||||
|
|
||||||
@override
|
|
||||||
int? toJson(UnreadType? object) => object?.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@immutable
|
|
||||||
class UnreadType {
|
|
||||||
final int value;
|
|
||||||
const UnreadType(this.value);
|
|
||||||
|
|
||||||
static const none = UnreadType(0);
|
|
||||||
static const normal = UnreadType(1);
|
|
||||||
static const notify = UnreadType(2);
|
|
||||||
static const highlight = UnreadType(4);
|
|
||||||
static const sound = UnreadType(8);
|
|
||||||
|
|
||||||
bool get isNone => value == 0;
|
|
||||||
bool get isNormal => (value & 1) != 0;
|
|
||||||
bool get shouldNotify => (value & 2) != 0;
|
|
||||||
bool get isHighlighted => (value & 4) != 0;
|
|
||||||
bool get playsSound => (value & 8) != 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
import "package:freezed_annotation/freezed_annotation.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
part "paginate.freezed.dart";
|
part "paginate.freezed.dart";
|
||||||
part "paginate.g.dart";
|
part "paginate.g.dart";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:freezed_annotation/freezed_annotation.dart";
|
import "package:freezed_annotation/freezed_annotation.dart";
|
||||||
import "package:nexus/models/event/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/models/read_receipt.dart";
|
import "package:nexus/models/read_receipt.dart";
|
||||||
import "package:nexus/models/room_metadata.dart";
|
import "package:nexus/models/room_metadata.dart";
|
||||||
part "room.freezed.dart";
|
part "room.freezed.dart";
|
||||||
|
|
|
||||||
24
pubspec.lock
24
pubspec.lock
|
|
@ -680,23 +680,21 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.5"
|
||||||
json_annotation:
|
json_annotation:
|
||||||
dependency: "direct overridden"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: json_annotation
|
name: json_annotation
|
||||||
ref: "feature/json-key-flatten-2"
|
sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8
|
||||||
resolved-ref: "292d155b643b5f6fd956399d16a45711a0512ecd"
|
url: "https://pub.dev"
|
||||||
url: "https://github.com/helgoboss/json_serializable.dart"
|
source: hosted
|
||||||
source: git
|
version: "4.11.0"
|
||||||
version: "4.9.1-wip"
|
|
||||||
json_serializable:
|
json_serializable:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
path: json_serializable
|
name: json_serializable
|
||||||
ref: "feature/json-key-flatten-2"
|
sha256: "44729f5c45748e6748f6b9a57ab8f7e4336edc8ae41fc295070e3814e616a6c0"
|
||||||
resolved-ref: "292d155b643b5f6fd956399d16a45711a0512ecd"
|
url: "https://pub.dev"
|
||||||
url: "https://github.com/helgoboss/json_serializable.dart"
|
source: hosted
|
||||||
source: git
|
version: "6.13.0"
|
||||||
version: "6.11.4"
|
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
14
pubspec.yaml
14
pubspec.yaml
|
|
@ -11,13 +11,6 @@ flutter:
|
||||||
environment:
|
environment:
|
||||||
sdk: "3.11.4"
|
sdk: "3.11.4"
|
||||||
|
|
||||||
dependency_overrides:
|
|
||||||
json_annotation:
|
|
||||||
git:
|
|
||||||
url: https://github.com/helgoboss/json_serializable.dart
|
|
||||||
ref: feature/json-key-flatten-2
|
|
||||||
path: json_annotation
|
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
@ -42,6 +35,7 @@ dependencies:
|
||||||
color_hash: 1.0.1
|
color_hash: 1.0.1
|
||||||
flutter_widget_from_html_core: 0.17.2
|
flutter_widget_from_html_core: 0.17.2
|
||||||
flutter_svg: 2.3.0
|
flutter_svg: 2.3.0
|
||||||
|
json_annotation: 4.11.0
|
||||||
shared_preferences: 2.5.5
|
shared_preferences: 2.5.5
|
||||||
fluttertagger: 2.3.2
|
fluttertagger: 2.3.2
|
||||||
dynamic_polls: 0.0.7
|
dynamic_polls: 0.0.7
|
||||||
|
|
@ -65,11 +59,7 @@ dev_dependencies:
|
||||||
freezed: 3.2.5
|
freezed: 3.2.5
|
||||||
riverpod_lint: 3.1.3
|
riverpod_lint: 3.1.3
|
||||||
flutter_launcher_icons: 0.14.4
|
flutter_launcher_icons: 0.14.4
|
||||||
json_serializable:
|
json_serializable: 6.13.0
|
||||||
git:
|
|
||||||
url: https://github.com/helgoboss/json_serializable.dart
|
|
||||||
ref: feature/json-key-flatten-2
|
|
||||||
path: json_serializable
|
|
||||||
|
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
ios: true
|
ios: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue