Fix one unpin + new pin not highlighting.
This commit is contained in:
1 parent
a18e3d534c
commit
7b4e1cfe98
2 files changed
+15
-3
No files matched your search
@@ -320,8 +320,10 @@ export function RoomViewHeader() {
|
||||
const newPins = pinnedIds.slice(lastSeenIndex + 1);
|
||||
setUnreadPinsCount(newPins.length);
|
||||
} else {
|
||||
const countDiff = pinnedIds.length - (pinMarker?.count ?? 0);
|
||||
setUnreadPinsCount(countDiff > 0 ? countDiff : 0);
|
||||
const oldCount = pinMarker?.count ?? 0;
|
||||
const startIndex = Math.max(0, oldCount - 1);
|
||||
const newCount = pinnedIds.length > 0 ? pinnedIds.length - startIndex : 0;
|
||||
setUnreadPinsCount(Math.max(0, newCount));
|
||||
}
|
||||
};
|
||||
checkUnreads();
|
||||
|
||||
@@ -298,10 +298,12 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
const pinMarker = useMemo(() =>
|
||||
room.getAccountData(AccountDataEvent.SablePinStatus)?.getContent(),
|
||||
[room]);
|
||||
|
||||
const lastSeenIndex = useMemo(() => {
|
||||
if (!pinMarker?.last_seen_id) return -1;
|
||||
return pinnedEvents.indexOf(pinMarker.last_seen_id);
|
||||
}, [pinnedEvents, pinMarker]);
|
||||
|
||||
const hasNewContent = pinMarker?.hash !== currentHash;
|
||||
|
||||
const virtualizer = useVirtualizer({
|
||||
@@ -513,7 +515,15 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
if (!eventId) return null;
|
||||
|
||||
const originalIndex = pinnedEvents.indexOf(eventId);
|
||||
const isNew = hasNewContent && (lastSeenIndex === -1 || originalIndex > lastSeenIndex);
|
||||
let isNew = false;
|
||||
if (pinMarker?.hash !== currentHash) {
|
||||
if (lastSeenIndex !== -1) {
|
||||
isNew = originalIndex > lastSeenIndex;
|
||||
} else {
|
||||
const oldCount = pinMarker?.count ?? 0;
|
||||
isNew = originalIndex >= (oldCount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
|
||||
Reference in new issue
Block a user