mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-30 16:29:30 +01:00
Merge branch 'krille/read-marker' into 'main'
fix: Set read marker only on user interaction See merge request famedly/fluffychat!747
This commit is contained in:
commit
6f7ea70a50
@ -147,6 +147,7 @@ class ChatController extends State<Chat> {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
setReadMarker();
|
||||
if (scrollController.position.pixels ==
|
||||
scrollController.position.maxScrollExtent &&
|
||||
timeline!.events.isNotEmpty &&
|
||||
@ -201,8 +202,8 @@ class ChatController extends State<Chat> {
|
||||
if (timeline == null) {
|
||||
timeline = await room!.getTimeline(onUpdate: updateView);
|
||||
if (timeline!.events.isNotEmpty) {
|
||||
// ignore: unawaited_futures
|
||||
if (room!.markedUnread) room!.markUnread(false);
|
||||
setReadMarker();
|
||||
}
|
||||
|
||||
// when the scroll controller is attached we want to scroll to an event id, if specified
|
||||
@ -220,15 +221,24 @@ class ChatController extends State<Chat> {
|
||||
}
|
||||
filteredEvents = timeline!.getFilteredEvents(unfolded: unfolded);
|
||||
timeline!.requestKeys();
|
||||
if ((room!.hasNewMessages || room!.notificationCount > 0) &&
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void>? _setReadMarkerFuture;
|
||||
|
||||
void setReadMarker([_]) {
|
||||
if (_setReadMarkerFuture == null &&
|
||||
(room!.hasNewMessages || room!.notificationCount > 0) &&
|
||||
timeline != null &&
|
||||
timeline!.events.isNotEmpty &&
|
||||
Matrix.of(context).webHasFocus) {
|
||||
Logs().v('Set read marker...');
|
||||
// ignore: unawaited_futures
|
||||
timeline!.setReadMarker();
|
||||
_setReadMarkerFuture = timeline!.setReadMarker().then((_) {
|
||||
_setReadMarkerFuture = null;
|
||||
});
|
||||
room!.client.updateIosBadge();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -900,6 +910,7 @@ class ChatController extends State<Chat> {
|
||||
}
|
||||
|
||||
void onInputBarChanged(String text) {
|
||||
setReadMarker();
|
||||
if (text.endsWith(' ') && matrix!.hasComplexBundles) {
|
||||
final clients = currentRoomBundle;
|
||||
for (final client in clients) {
|
||||
|
@ -156,6 +156,8 @@ class ChatView extends StatelessWidget {
|
||||
redirector.stopRedirection();
|
||||
}
|
||||
},
|
||||
child: GestureDetector(
|
||||
onTapDown: controller.setReadMarker,
|
||||
child: StreamBuilder(
|
||||
stream: controller.room!.onUpdate.stream
|
||||
.rateLimit(const Duration(milliseconds: 250)),
|
||||
@ -229,9 +231,8 @@ class ChatView extends StatelessWidget {
|
||||
}
|
||||
if (controller.timeline == null) {
|
||||
return const Center(
|
||||
child:
|
||||
CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2),
|
||||
child: CircularProgressIndicator
|
||||
.adaptive(strokeWidth: 2),
|
||||
);
|
||||
}
|
||||
|
||||
@ -277,7 +278,8 @@ class ChatView extends StatelessWidget {
|
||||
)
|
||||
: controller.canLoadMore
|
||||
? Center(
|
||||
child: OutlinedButton(
|
||||
child:
|
||||
OutlinedButton(
|
||||
style:
|
||||
OutlinedButton
|
||||
.styleFrom(
|
||||
@ -306,7 +308,8 @@ class ChatView extends StatelessWidget {
|
||||
)
|
||||
: AutoScrollTag(
|
||||
key: ValueKey(controller
|
||||
.filteredEvents[i - 1]
|
||||
.filteredEvents[
|
||||
i - 1]
|
||||
.eventId),
|
||||
index: i - 1,
|
||||
controller: controller
|
||||
@ -340,13 +343,11 @@ class ChatView extends StatelessWidget {
|
||||
i - 1],
|
||||
onInfoTab: controller
|
||||
.showEventInfo,
|
||||
onAvatarTab:
|
||||
(Event event) =>
|
||||
onAvatarTab: (Event event) =>
|
||||
showModalBottomSheet(
|
||||
context:
|
||||
context,
|
||||
builder:
|
||||
(c) =>
|
||||
builder: (c) =>
|
||||
UserBottomSheet(
|
||||
user: event
|
||||
.sender,
|
||||
@ -447,6 +448,7 @@ class ChatView extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user