Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 13ec19c

Browse files
authored
Sort the pinning message list in the same order than the banner (#12937)
1 parent 19f8b44 commit 13ec19c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/components/views/right_panel/PinnedMessagesCard.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { filterBoolean } from "../../../utils/arrays";
3434
import Modal from "../../../Modal";
3535
import { UnpinAllDialog } from "../dialogs/UnpinAllDialog";
3636
import EmptyState from "./EmptyState";
37-
import { useFetchedPinnedEvents, usePinnedEvents, useReadPinnedEvents } from "../../../hooks/usePinnedEvents";
37+
import { usePinnedEvents, useReadPinnedEvents, useSortedFetchedPinnedEvents } from "../../../hooks/usePinnedEvents";
3838

3939
/**
4040
* List the pinned messages in a room inside a Card.
@@ -59,7 +59,7 @@ export function PinnedMessagesCard({ room, onClose, permalinkCreator }: PinnedMe
5959
const roomContext = useRoomContext();
6060
const pinnedEventIds = usePinnedEvents(room);
6161
const readPinnedEvents = useReadPinnedEvents(room);
62-
const pinnedEvents = useFetchedPinnedEvents(room, pinnedEventIds);
62+
const pinnedEvents = useSortedFetchedPinnedEvents(room, pinnedEventIds);
6363

6464
useEffect(() => {
6565
if (!cli || cli.isGuest()) return; // nothing to do

test/components/views/right_panel/PinnedMessagesCard-test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ describe("<PinnedMessagesCard />", () => {
165165
room: "!room:example.org",
166166
user: "@alice:example.org",
167167
msg: "First pinned message",
168+
ts: 2,
168169
});
169170
const pin2 = mkMessage({
170171
event: true,
171172
room: "!room:example.org",
172173
user: "@alice:example.org",
173174
msg: "The second one",
175+
ts: 1,
174176
});
175177

176178
it("should show spinner whilst loading", async () => {

test/components/views/right_panel/__snapshots__/PinnedMessagesCard-test.tsx.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ exports[`<PinnedMessagesCard /> should show two pinned messages 1`] = `
184184
class="mx_EventTile_body translate"
185185
dir="auto"
186186
>
187-
The second one
187+
First pinned message
188188
</div>
189189
</div>
190190
</div>
@@ -250,7 +250,7 @@ exports[`<PinnedMessagesCard /> should show two pinned messages 1`] = `
250250
class="mx_EventTile_body translate"
251251
dir="auto"
252252
>
253-
First pinned message
253+
The second one
254254
</div>
255255
</div>
256256
</div>
@@ -379,7 +379,7 @@ exports[`<PinnedMessagesCard /> unpin all should not allow to unpinall 1`] = `
379379
class="mx_EventTile_body translate"
380380
dir="auto"
381381
>
382-
The second one
382+
First pinned message
383383
</div>
384384
</div>
385385
</div>
@@ -445,7 +445,7 @@ exports[`<PinnedMessagesCard /> unpin all should not allow to unpinall 1`] = `
445445
class="mx_EventTile_body translate"
446446
dir="auto"
447447
>
448-
First pinned message
448+
The second one
449449
</div>
450450
</div>
451451
</div>

0 commit comments

Comments
 (0)