Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Pinned at the top

Manav Rathiea0bd31480e3
diff --git a/web/apps/auth/src/services/code.ts b/web/apps/auth/src/services/code.ts
index 2d03b68ca4..739fea286c 100644
--- a/web/apps/auth/src/services/code.ts
+++ b/web/apps/auth/src/services/code.ts
@@ -63,10 +63,17 @@ export interface CodeDisplay {
* user and will be automatically permanenently deleted after some time).
*/
trashed?: boolean;
+ /**
+ * `true` if this code has been pinned by the user.
+ *
+ * Pinned codes show at the top of the list of codes.
+ */
+ pinned?: boolean;
}
const CodeDisplay = z.object({
trashed: z.boolean().nullish().transform(nullToUndefined),
+ pinned: z.boolean().nullish().transform(nullToUndefined),
});
/**
diff --git a/web/apps/auth/src/services/remote.ts b/web/apps/auth/src/services/remote.ts
index 96bca4a6b2..caed117af8 100644
--- a/web/apps/auth/src/services/remote.ts
+++ b/web/apps/auth/src/services/remote.ts
@@ -32,6 +32,12 @@ export const getAuthCodes = async (masterKey: Uint8Array): Promise<Code[]> => {
return !f.codeDisplay?.trashed;
})
.sort((a, b) => {
+ // If only one of them is pinned, prefer it.
+ if (a.codeDisplay?.pinned && !b.codeDisplay?.pinned) return -1;
+ if (!a.codeDisplay?.pinned && b.codeDisplay?.pinned) return 1;
+ // If we get here, either both are pinned, or none are...
+
+ // Sort by issuer, alphabetically.
if (a.issuer && b.issuer) {
return a.issuer.localeCompare(b.issuer);
}