Skip to content

Commit

Permalink
Fix omnichannel bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Aug 26, 2022
1 parent 40816f2 commit e0a961b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/meteor/app/ui-utils/client/lib/RoomManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const openedRooms: Record<
template?: Blaze.View;
streamActive?: boolean;
unreadSince: ReactiveVar<Date | undefined>;
lastSeen?: Date;
lastSeen: Date;
unreadFirstId?: string;
}
> = {};
Expand Down Expand Up @@ -105,9 +105,8 @@ function closeOlderRooms() {
if (Object.keys(openedRooms).length <= maxRoomsOpen) {
return;
}

const roomsToClose = Object.values(openedRooms)
.sort((a, b) => (a.lastSeen?.getTime() ?? 0) - (b.lastSeen?.getTime() ?? 0))
.sort((a, b) => b.lastSeen.getTime() - a.lastSeen.getTime())
.slice(maxRoomsOpen);
return Array.from(roomsToClose).map((roomToClose) => close(roomToClose.typeName));
}
Expand Down Expand Up @@ -225,6 +224,7 @@ function open({ typeName, rid }: { typeName: string; rid: IRoom['_id'] }) {
active: false,
ready: false,
unreadSince: new ReactiveVar(undefined),
lastSeen: new Date(),
};
}

Expand Down

0 comments on commit e0a961b

Please sign in to comment.