Read receipt support

Fixes #93
This commit is contained in:
Henry Hiles 2026-10-21 22:58:06 -04:00
commit e38307657d
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
5 changed files with 445 additions and 63 deletions

View file

@ -1,6 +1,7 @@
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";
part "paginate.freezed.dart";
part "paginate.g.dart";
@ -10,6 +11,9 @@ part "paginate.g.dart";
class const Paginate({
required final IList<Event> events,
required final IList<Event> relatedEvents,
/// Read receipts for the events, by event ID.
final IMap<String, IList<ReadReceipt>> receipts = const .empty(),
required final bool hasMore,
}) with _$Paginate {
Map<String, Object?> toJson() => _$PaginateToJson(this);

View file

@ -13,6 +13,11 @@ class const ReadReceipt({
required final String eventId,
@EpochDateTimeConverter() required final DateTime timestamp,
}) with _$ReadReceipt {
String get thread => switch (threadId) {
final threadId? when threadId.isNotEmpty => threadId,
_ => "main",
};
Map<String, Object?> toJson() => _$ReadReceiptToJson(this);
factory ReadReceipt.fromJson(Map<String, Object?> json) =>

View file

@ -1,7 +1,7 @@
import "package:material_ui/material_ui.dart";
import "package:freezed_annotation/freezed_annotation.dart";
import "package:nexus/models/room_order.dart";
import "package:nexus/models/typing_indicators.dart";
import "package:nexus/models/show_and_send.dart";
part "settings.freezed.dart";
part "settings.g.dart";
@ -17,7 +17,11 @@ class const Settings({
final bool swipeToReply = false,
final bool hideMembershipEvents = false,
final RoomOrder roomOrder = .unreadFirst,
final TypingIndicators typingIndicators = .showAndSend,
final ShowAndSend typingIndicators = .showAndSend,
/// When not sending, read receipts are still sent privately, so that the
/// user's other devices know what has been read.
final ShowAndSend readReceipts = .showAndSend,
}) with _$Settings {
Map<String, Object?> toJson() => _$SettingsToJson(this);

View file

@ -0,0 +1,2 @@
/// Whether to show something from others, and send it to them, e.g. typing indicators or read receipts.
enum ShowAndSend { showAndSend, show, neither }

View file

@ -1 +0,0 @@
enum TypingIndicators { showAndSend, show, neither }