Show date for msgs older than a day

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura
2021-12-08 13:37:25 +05:30
parent e20b9d054d
commit ca55141276
4 changed files with 20 additions and 13 deletions

View File

@@ -22,9 +22,9 @@ function useJumpToEvent(roomTimeline) {
roomTimeline.loadEventTimeline(eventId);
};
const cancelJumpToEvent = (mEvent) => {
const cancelJumpToEvent = () => {
roomTimeline.markAllAsRead();
setEventId(null);
if (!mEvent) roomTimeline.markAllAsRead();
};
useEffect(() => {
@@ -35,10 +35,12 @@ function useJumpToEvent(roomTimeline) {
if (!readEventId.startsWith('~') && !roomTimeline.hasEventInTimeline(readEventId)) {
setEventId(readEventId);
}
roomTimeline.on(cons.events.roomTimeline.MARKED_AS_READ, cancelJumpToEvent);
const handleMarkAsRead = () => setEventId(null);
roomTimeline.on(cons.events.roomTimeline.MARKED_AS_READ, handleMarkAsRead);
return () => {
roomTimeline.removeListener(cons.events.roomTimeline.MARKED_AS_READ, cancelJumpToEvent);
roomTimeline.removeListener(cons.events.roomTimeline.MARKED_AS_READ, handleMarkAsRead);
setEventId(null);
};
}, [roomTimeline]);