Skip to content
Snippets Groups Projects
Unverified Commit 13ec19c2 authored by Florian Duros's avatar Florian Duros Committed by GitHub
Browse files

Sort the pinning message list in the same order than the banner (#12937)

parent 19f8b447
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,7 @@ import { filterBoolean } from "../../../utils/arrays"; ...@@ -34,7 +34,7 @@ import { filterBoolean } from "../../../utils/arrays";
import Modal from "../../../Modal"; import Modal from "../../../Modal";
import { UnpinAllDialog } from "../dialogs/UnpinAllDialog"; import { UnpinAllDialog } from "../dialogs/UnpinAllDialog";
import EmptyState from "./EmptyState"; import EmptyState from "./EmptyState";
import { useFetchedPinnedEvents, usePinnedEvents, useReadPinnedEvents } from "../../../hooks/usePinnedEvents"; import { usePinnedEvents, useReadPinnedEvents, useSortedFetchedPinnedEvents } from "../../../hooks/usePinnedEvents";
/** /**
* List the pinned messages in a room inside a Card. * List the pinned messages in a room inside a Card.
...@@ -59,7 +59,7 @@ export function PinnedMessagesCard({ room, onClose, permalinkCreator }: PinnedMe ...@@ -59,7 +59,7 @@ export function PinnedMessagesCard({ room, onClose, permalinkCreator }: PinnedMe
const roomContext = useRoomContext(); const roomContext = useRoomContext();
const pinnedEventIds = usePinnedEvents(room); const pinnedEventIds = usePinnedEvents(room);
const readPinnedEvents = useReadPinnedEvents(room); const readPinnedEvents = useReadPinnedEvents(room);
const pinnedEvents = useFetchedPinnedEvents(room, pinnedEventIds); const pinnedEvents = useSortedFetchedPinnedEvents(room, pinnedEventIds);
useEffect(() => { useEffect(() => {
if (!cli || cli.isGuest()) return; // nothing to do if (!cli || cli.isGuest()) return; // nothing to do
......
...@@ -165,12 +165,14 @@ describe("<PinnedMessagesCard />", () => { ...@@ -165,12 +165,14 @@ describe("<PinnedMessagesCard />", () => {
room: "!room:example.org", room: "!room:example.org",
user: "@alice:example.org", user: "@alice:example.org",
msg: "First pinned message", msg: "First pinned message",
ts: 2,
}); });
const pin2 = mkMessage({ const pin2 = mkMessage({
event: true, event: true,
room: "!room:example.org", room: "!room:example.org",
user: "@alice:example.org", user: "@alice:example.org",
msg: "The second one", msg: "The second one",
ts: 1,
}); });
it("should show spinner whilst loading", async () => { it("should show spinner whilst loading", async () => {
......
...@@ -184,7 +184,7 @@ exports[`<PinnedMessagesCard /> should show two pinned messages 1`] = ` ...@@ -184,7 +184,7 @@ exports[`<PinnedMessagesCard /> should show two pinned messages 1`] = `
class="mx_EventTile_body translate" class="mx_EventTile_body translate"
dir="auto" dir="auto"
> >
The second one First pinned message
</div> </div>
</div> </div>
</div> </div>
...@@ -250,7 +250,7 @@ exports[`<PinnedMessagesCard /> should show two pinned messages 1`] = ` ...@@ -250,7 +250,7 @@ exports[`<PinnedMessagesCard /> should show two pinned messages 1`] = `
class="mx_EventTile_body translate" class="mx_EventTile_body translate"
dir="auto" dir="auto"
> >
First pinned message The second one
</div> </div>
</div> </div>
</div> </div>
...@@ -379,7 +379,7 @@ exports[`<PinnedMessagesCard /> unpin all should not allow to unpinall 1`] = ` ...@@ -379,7 +379,7 @@ exports[`<PinnedMessagesCard /> unpin all should not allow to unpinall 1`] = `
class="mx_EventTile_body translate" class="mx_EventTile_body translate"
dir="auto" dir="auto"
> >
The second one First pinned message
</div> </div>
</div> </div>
</div> </div>
...@@ -445,7 +445,7 @@ exports[`<PinnedMessagesCard /> unpin all should not allow to unpinall 1`] = ` ...@@ -445,7 +445,7 @@ exports[`<PinnedMessagesCard /> unpin all should not allow to unpinall 1`] = `
class="mx_EventTile_body translate" class="mx_EventTile_body translate"
dir="auto" dir="auto"
> >
First pinned message The second one
</div> </div>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment