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) {
|
if (!mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setReadMarker();
|
||||||
if (scrollController.position.pixels ==
|
if (scrollController.position.pixels ==
|
||||||
scrollController.position.maxScrollExtent &&
|
scrollController.position.maxScrollExtent &&
|
||||||
timeline!.events.isNotEmpty &&
|
timeline!.events.isNotEmpty &&
|
||||||
@ -201,8 +202,8 @@ class ChatController extends State<Chat> {
|
|||||||
if (timeline == null) {
|
if (timeline == null) {
|
||||||
timeline = await room!.getTimeline(onUpdate: updateView);
|
timeline = await room!.getTimeline(onUpdate: updateView);
|
||||||
if (timeline!.events.isNotEmpty) {
|
if (timeline!.events.isNotEmpty) {
|
||||||
// ignore: unawaited_futures
|
|
||||||
if (room!.markedUnread) room!.markUnread(false);
|
if (room!.markedUnread) room!.markUnread(false);
|
||||||
|
setReadMarker();
|
||||||
}
|
}
|
||||||
|
|
||||||
// when the scroll controller is attached we want to scroll to an event id, if specified
|
// 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);
|
filteredEvents = timeline!.getFilteredEvents(unfolded: unfolded);
|
||||||
timeline!.requestKeys();
|
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 != null &&
|
||||||
timeline!.events.isNotEmpty &&
|
timeline!.events.isNotEmpty &&
|
||||||
Matrix.of(context).webHasFocus) {
|
Matrix.of(context).webHasFocus) {
|
||||||
|
Logs().v('Set read marker...');
|
||||||
// ignore: unawaited_futures
|
// ignore: unawaited_futures
|
||||||
timeline!.setReadMarker();
|
_setReadMarkerFuture = timeline!.setReadMarker().then((_) {
|
||||||
|
_setReadMarkerFuture = null;
|
||||||
|
});
|
||||||
room!.client.updateIosBadge();
|
room!.client.updateIosBadge();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -900,6 +910,7 @@ class ChatController extends State<Chat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onInputBarChanged(String text) {
|
void onInputBarChanged(String text) {
|
||||||
|
setReadMarker();
|
||||||
if (text.endsWith(' ') && matrix!.hasComplexBundles) {
|
if (text.endsWith(' ') && matrix!.hasComplexBundles) {
|
||||||
final clients = currentRoomBundle;
|
final clients = currentRoomBundle;
|
||||||
for (final client in clients) {
|
for (final client in clients) {
|
||||||
|
@ -156,6 +156,8 @@ class ChatView extends StatelessWidget {
|
|||||||
redirector.stopRedirection();
|
redirector.stopRedirection();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
child: GestureDetector(
|
||||||
|
onTapDown: controller.setReadMarker,
|
||||||
child: StreamBuilder(
|
child: StreamBuilder(
|
||||||
stream: controller.room!.onUpdate.stream
|
stream: controller.room!.onUpdate.stream
|
||||||
.rateLimit(const Duration(milliseconds: 250)),
|
.rateLimit(const Duration(milliseconds: 250)),
|
||||||
@ -229,9 +231,8 @@ class ChatView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
if (controller.timeline == null) {
|
if (controller.timeline == null) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child:
|
child: CircularProgressIndicator
|
||||||
CircularProgressIndicator.adaptive(
|
.adaptive(strokeWidth: 2),
|
||||||
strokeWidth: 2),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +278,8 @@ class ChatView extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: controller.canLoadMore
|
: controller.canLoadMore
|
||||||
? Center(
|
? Center(
|
||||||
child: OutlinedButton(
|
child:
|
||||||
|
OutlinedButton(
|
||||||
style:
|
style:
|
||||||
OutlinedButton
|
OutlinedButton
|
||||||
.styleFrom(
|
.styleFrom(
|
||||||
@ -306,7 +308,8 @@ class ChatView extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: AutoScrollTag(
|
: AutoScrollTag(
|
||||||
key: ValueKey(controller
|
key: ValueKey(controller
|
||||||
.filteredEvents[i - 1]
|
.filteredEvents[
|
||||||
|
i - 1]
|
||||||
.eventId),
|
.eventId),
|
||||||
index: i - 1,
|
index: i - 1,
|
||||||
controller: controller
|
controller: controller
|
||||||
@ -340,13 +343,11 @@ class ChatView extends StatelessWidget {
|
|||||||
i - 1],
|
i - 1],
|
||||||
onInfoTab: controller
|
onInfoTab: controller
|
||||||
.showEventInfo,
|
.showEventInfo,
|
||||||
onAvatarTab:
|
onAvatarTab: (Event event) =>
|
||||||
(Event event) =>
|
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context:
|
context:
|
||||||
context,
|
context,
|
||||||
builder:
|
builder: (c) =>
|
||||||
(c) =>
|
|
||||||
UserBottomSheet(
|
UserBottomSheet(
|
||||||
user: event
|
user: event
|
||||||
.sender,
|
.sender,
|
||||||
@ -447,6 +448,7 @@ class ChatView extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user