refactored internal documentation and simplified comments across chat BLoCs, file viewer, and navigation components

This commit is contained in:
2026-05-10 17:01:50 +02:00
parent a0bc46f522
commit 1a11b9ac60
8 changed files with 68 additions and 185 deletions
@@ -32,9 +32,7 @@ class ChatListBloc
return super.close();
}
/// Sets (or clears) the recurring background refresh. Silent so the
/// loading bar doesn't blink several times a minute; pull-to-refresh
/// and tab-activation refreshes are non-silent for explicit feedback.
/// Silent refresh — explicit pull-to-refresh and tab-activation are non-silent.
void setAutoRefreshInterval(Duration? interval) {
if (interval == _autoRefreshInterval) return;
_autoRefreshInterval = interval;
@@ -107,10 +105,6 @@ class ChatListBloc
await refresh();
}
/// Returns the cached `lastReadMessage` for the room with [token], or
/// `null` if the room is not (yet) known. Used by [ChatBloc] to skip
/// redundant server read-marker calls when the local cache already
/// reflects the same position.
int? lastReadMessageFor(String token) {
final rooms = innerState?.rooms;
if (rooms == null) return null;
@@ -120,9 +114,7 @@ class ChatListBloc
return null;
}
/// Optimistically clears the unread counter for [token] so the tile
/// reacts before a refresh roundtrip lands. Server-side mark-as-read
/// is the caller's job (see [ChatBloc.sendServerReadMarker]).
/// Optimistic — server-side mark-as-read is the caller's job.
void markRoomAsRead(String token, int lastMessageId) {
_mutateRoom(token, (r) {
if (r.unreadMessages == 0 && r.lastReadMessage >= lastMessageId) {
@@ -136,10 +128,7 @@ class ChatListBloc
});
}
/// Pushes a freshly-received message into the matching room tile so the
/// list shows the right preview text + activity timestamp before the
/// next full refresh lands. Also clears unread because the long-poll
/// only feeds this in for an actively-open chat.
/// Clears unread too — long-poll only feeds this in for an actively-open chat.
void applyIncomingMessage(String token, GetChatResponseObject message) {
_mutateRoom(token, (r) {
final wasRead =
@@ -156,10 +145,7 @@ class ChatListBloc
});
}
/// Mutates the room with [token] in-place via [mutator] (returning
/// true if anything changed) and re-emits if so. Builds a fresh
/// [GetRoomResponse] so equality-by-identity in the bloc state
/// recognises the change and rebuilds.
/// Re-wraps in a fresh [GetRoomResponse] so identity-based equality picks it up.
void _mutateRoom(
String token,
bool Function(GetRoomResponseObject room) mutator,