mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 23:10:28 +03:00
Fix unable to mark as read some rooms
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
ca55141276
commit
27d0a88b36
3 changed files with 13 additions and 17 deletions
|
|
@ -58,7 +58,7 @@ function isTimelineLinked(tm1, tm2) {
|
|||
}
|
||||
|
||||
class RoomTimeline extends EventEmitter {
|
||||
constructor(roomId) {
|
||||
constructor(roomId, notifications) {
|
||||
super();
|
||||
// These are local timelines
|
||||
this.timeline = [];
|
||||
|
|
@ -69,6 +69,7 @@ class RoomTimeline extends EventEmitter {
|
|||
this.matrixClient = initMatrix.matrixClient;
|
||||
this.roomId = roomId;
|
||||
this.room = this.matrixClient.getRoom(roomId);
|
||||
this.notifications = notifications;
|
||||
|
||||
this.liveTimeline = this.room.getLiveTimeline();
|
||||
this.activeTimeline = this.liveTimeline;
|
||||
|
|
@ -208,6 +209,7 @@ class RoomTimeline extends EventEmitter {
|
|||
|
||||
markAllAsRead() {
|
||||
const readEventId = this.getReadUpToEventId();
|
||||
this.notifications.deleteNoti(this.roomId);
|
||||
if (this.timeline.length === 0) return;
|
||||
const latestEvent = this.timeline[this.timeline.length - 1];
|
||||
if (readEventId === latestEvent.getId()) return;
|
||||
|
|
@ -215,15 +217,6 @@ class RoomTimeline extends EventEmitter {
|
|||
this.emit(cons.events.roomTimeline.MARKED_AS_READ, latestEvent);
|
||||
}
|
||||
|
||||
markAsRead(eventId) {
|
||||
if (this.hasEventInTimeline(eventId)) {
|
||||
const mEvent = this.findEventById(eventId);
|
||||
if (!mEvent) return;
|
||||
this.matrixClient.sendReadReceipt(mEvent);
|
||||
this.emit(cons.events.roomTimeline.MARKED_AS_READ, mEvent);
|
||||
}
|
||||
}
|
||||
|
||||
hasEventInTimeline(eventId, timeline = this.activeTimeline) {
|
||||
const timelineSet = this.getUnfilteredTimelineSet();
|
||||
const eventTimeline = timelineSet.getTimelineForEvent(eventId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue