Notifications page
Doesn't yet allow for jumping to events
This commit is contained in:
parent
9e7fcdbef7
commit
23e01c7a0d
12 changed files with 296 additions and 139 deletions
|
|
@ -29,7 +29,7 @@ class const Event({
|
|||
final String? sendError,
|
||||
final IMap<String, int> reactions = const IMap.empty(),
|
||||
@JsonKey(name: "last_edit_rowid") final int lastEditRowId = 0,
|
||||
@UnreadTypeConverter() final UnreadType? unreadType,
|
||||
final UnreadType? unreadType,
|
||||
final Profile? pmp,
|
||||
required final Content content,
|
||||
required final Content? previousContent,
|
||||
|
|
@ -91,22 +91,10 @@ class const LocalContent({
|
|||
_$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);
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
class const UnreadType(final int value) with _$UnreadType {
|
||||
factory UnreadType.fromJson(int json) => UnreadType(json);
|
||||
int toJson() => value;
|
||||
|
||||
static const none = UnreadType(0);
|
||||
static const normal = UnreadType(1);
|
||||
|
|
@ -114,9 +102,9 @@ class UnreadType {
|
|||
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;
|
||||
bool isNone() => value == 0;
|
||||
bool isNormal() => (value & 1) != 0;
|
||||
bool shouldNotify() => (value & 2) != 0;
|
||||
bool isHighlighted() => (value & 4) != 0;
|
||||
bool playsSound() => (value & 8) != 0;
|
||||
}
|
||||
|
|
|
|||
19
lib/models/requests/get_mentions.dart
Normal file
19
lib/models/requests/get_mentions.dart
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
import "package:nexus/models/epoch_date_time_converter.dart";
|
||||
import "package:nexus/models/event.dart";
|
||||
part "get_mentions.freezed.dart";
|
||||
part "get_mentions.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class GetMentionsRequest({
|
||||
@EpochDateTimeConverter() required final DateTime maxTimestamp,
|
||||
@JsonKey(name: "type") required final UnreadType unreadType,
|
||||
required final int limit,
|
||||
final String? roomId,
|
||||
}) with _$GetMentionsRequest {
|
||||
Map<String, Object?> toJson() => _$GetMentionsRequestToJson(this);
|
||||
|
||||
factory GetMentionsRequest.fromJson(Map<String, Object?> json) =>
|
||||
_$GetMentionsRequestFromJson(json);
|
||||
}
|
||||
Loading…
Reference in a new issue