@@ -4,6 +4,7 @@ import 'dart:async';
44import 'package:flutter_hooks/flutter_hooks.dart' ;
55import 'package:flutter/foundation.dart' ;
66import 'package:flutter/widgets.dart' ;
7+ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart' ;
78
89import '../../shared/read_state/read_state_format.dart' ;
910import '../../shared/read_state/read_state_provider.dart' ;
@@ -22,7 +23,8 @@ const readingDwell = Duration(milliseconds: 300);
2223/// catch-up marks read ordinary messages and that thread's replies. They do
2324/// not read mentions, broadcasts or DMs.
2425/// - The same channel catch-up also gives each loaded top-level mention and
25- /// broadcast through the bottom row its own `msg:` mark, at most the newest
26+ /// broadcast through the bottom row its own `msg:` mark (in a [flat]
27+ /// timeline, each mention through it, replies included), at most the newest
2628/// [catchUpMessageMarkLimit] , so a mention taller than the screen is still
2729/// read. Messages the reader marked unread keep that intent.
2830/// - Each fully visible message gets its own `msg:` mark unless its own mark,
@@ -38,7 +40,8 @@ const readingDwell = Duration(milliseconds: 300);
3840/// [bottom] is the newest message when its bottom edge is visible at the
3941/// bottom of the list; otherwise null. Set [threadRootId] when reading a
4042/// thread, and [isRootThread] when its head is the thread root rather than a
41- /// nested reply. [now] is the current Unix time in seconds; it defaults to
43+ /// nested reply. Set [flat] for a channel timeline that shows replies inline,
44+ /// as a Solo chat does. [now] is the current Unix time in seconds; it defaults to
4245/// the clock. The result maps each read-state context to its new time.
4346Map <String , int > readingMarks ({
4447 required ReadStateState readState,
@@ -50,6 +53,7 @@ Map<String, int> readingMarks({
5053 TimelineMessage ? bottom,
5154 String ? threadRootId,
5255 bool isRootThread = true ,
56+ bool flat = false ,
5357 int ? now,
5458}) {
5559 final marks = < String , int > {};
@@ -89,6 +93,7 @@ Map<String, int> readingMarks({
8993 loaded: loaded,
9094 bottom: bottom,
9195 threadRootId: threadRootId,
96+ flat: flat,
9297 )) {
9398 final catchUp = _catchUpMark (
9499 channelId: channelId,
@@ -102,7 +107,7 @@ Map<String, int> readingMarks({
102107 final attention = [
103108 for (final message in loaded)
104109 if (message.createdAt <= bottom.createdAt &&
105- (message.parentId == null || _isBroadcast (message)) &&
110+ (flat || message.parentId == null || _isBroadcast (message)) &&
106111 isHighPriorityEvent (message.tags, self) &&
107112 needsMark (message))
108113 message,
@@ -119,17 +124,16 @@ Map<String, int> readingMarks({
119124/// `buzz-app` , so a backlog cannot crowd older marks out of the synced budget.
120125const catchUpMessageMarkLimit = 128 ;
121126
122- /// Whether a row with these item-position edges counts as read: it lies
123- /// inside the reading area from [start] to [end] , or it is taller than that
124- /// area and covers all of it.
125- bool isReadableRow ({
126- required double leadingEdge,
127- required double trailingEdge,
127+ /// Whether a row at [position] counts as read: it lies inside the reading
128+ /// area from [start] to [end] , or it is taller than that area and covers all
129+ /// of it.
130+ bool isReadableRow (
131+ ItemPosition position, {
128132 required double start,
129133 required double end,
130134}) =>
131- (leadingEdge >= start && trailingEdge <= end) ||
132- (leadingEdge <= start && trailingEdge >= end);
135+ (position.itemLeadingEdge >= start && position.itemTrailingEdge <= end) ||
136+ (position.itemLeadingEdge <= start && position.itemTrailingEdge >= end);
133137
134138/// Whether [bottom] is the live bottom. A loaded message newer than the
135139/// bottom row means the list does not show it, for example after a jump
@@ -138,6 +142,7 @@ bool _showsNewest({
138142 required Iterable <TimelineMessage > loaded,
139143 required TimelineMessage bottom,
140144 required String ? threadRootId,
145+ required bool flat,
141146}) => ! loaded.any (
142147 (message) =>
143148 (threadRootId != null || ! isCollapsedHuddleEnding (message, loaded)) &&
@@ -146,7 +151,7 @@ bool _showsNewest({
146151 message.createdAt > bottom.createdAt &&
147152 (threadRootId != null
148153 ? _threadRootOf (message) == threadRootId
149- : message.parentId == null || _isBroadcast (message)),
154+ : flat || message.parentId == null || _isBroadcast (message)),
150155);
151156
152157/// The catch-up mark for [bottom] , or null when it would read nothing new.
0 commit comments