Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add support for pinned threads in the sidebar #1824

ClosedRobrusi(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/1824/headopened View on GitHub

Showing 5 changed files with 7 additions and 0 deletions (loading 4).

x
0 of 5 viewed, 5 left
7 additions and 0 deletionsapps/web/src/components/Sidebar.logic.tsModified
View file
@@ -14,6 +14,7 @@
updatedAt?: string | undefined;
};
type SidebarThreadSortInput = Pick<Thread, "createdAt" | "updatedAt"> & {
+ isPinned?: boolean;
latestUserMessageAt?: string | null;
messages?: Pick<Thread["messages"][number], "createdAt" | "role">[];
};
@@ -485,6 +486,12 @@
T extends Pick<Thread, "id" | "createdAt" | "updatedAt"> & SidebarThreadSortInput,
>(threads: readonly T[], sortOrder: SidebarThreadSortOrder): T[] {
return threads.toSorted((left, right) => {
+ const leftPinned = left.isPinned === true;
+ const rightPinned = right.isPinned === true;
+ if (leftPinned !== rightPinned) {
+ return rightPinned ? 1 : -1;
+ }
+​
const rightTimestamp = getThreadSortTimestamp(right, sortOrder);
const leftTimestamp = getThreadSortTimestamp(left, sortOrder);
const byTimestamp =
apps/web/src/components/Sidebar.tsxModified
View file
Loading the diff
apps/web/src/hooks/useThreadActions.tsModified
View file
Loading the diff