-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] TW-1399: counter update on scroll #1619
base: main
Are you sure you want to change the base?
Conversation
This PR has been deployed to https://linagora.github.io/twake-on-matrix/1619 |
@@ -139,8 +140,6 @@ class ChatController extends State<Chat> | |||
|
|||
Timer? _timestampTimer; | |||
|
|||
String _markerReadLocation = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you delete it?
It's related to display unread message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not really deleted it: this variable was only used in _findUnreadReceivedMessages
which I had to slightly modify:
twake-on-matrix/lib/pages/chat/chat.dart
Lines 262 to 293 in 85d942e
String? _findUnreadReceivedMessageId(String fullyRead) { | |
final unreadEvents = findUnreadReceivedMessages(fullyRead); | |
Logs().d( | |
"Chat::getFirstUnreadEvent(): Last unread event ${unreadEvents.last}", | |
); | |
return unreadEvents.isEmpty ? null : unreadEvents.last.eventId; | |
} | |
List<Event> findUnreadReceivedMessages(String fullyRead) { | |
final events = timeline!.events; | |
if (fullyRead != '' && fullyRead.isNotEmpty) { | |
final lastIndexReadEvent = events.indexWhere( | |
(event) => event.eventId == fullyRead, | |
); | |
if (lastIndexReadEvent > 0) { | |
final afterFullyRead = events.getRange(0, lastIndexReadEvent); | |
final unreadEvents = afterFullyRead | |
.where((event) => event.senderId != client.userID) | |
.toList(); | |
if (unreadEvents.isEmpty) return <Event>[]; | |
return unreadEvents; | |
} | |
} else { | |
return <Event>[]; | |
} | |
return <Event>[]; | |
} | |
@@ -83,119 +85,145 @@ class ChatEventList extends StatelessWidget { | |||
child: SelectionTextContainer( | |||
chatController: controller, | |||
focusNode: controller.selectionFocusNode, | |||
child: InViewNotifierListCustom( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you delete it?
It's related to diplay timestamp when you scrolling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not, I just added a widget above:
twake-on-matrix/lib/pages/chat/chat_event_list.dart
Lines 88 to 95 in 85d942e
child: ValueListenableBuilder( | |
valueListenable: controller.lastScrollDirection, | |
builder: (context, lastScrollDirection, _) => | |
InViewNotifierListCustom( | |
isInViewPortCondition: controller.isInViewPortCondition, | |
listViewCustom: ListView.custom( | |
padding: EdgeInsets.only( | |
top: 16, |
? controller.timeline!.events[currentEventIndex + 1] | ||
: null; | ||
|
||
return VisibilityDetector( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO: No need, InViewNotifierListCustom
is enough so you can detect a message when scrolled over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem when using InViewNotifierListCustom
for our purpose is that currently it checks the top of the screen to handle the display of the time stamp. But the notifications are updated when they are visible at the bottom of the screen.
I tried to expand the InViewNotifierListCustom
but it impact negatively the time stamp appearance. That's why I had to use VisibilityDetector
Issue: #1399
To do: