move sorting to backend

This commit is contained in:
mgabor
2024-04-21 18:05:35 +02:00
parent 29dd9ff4d8
commit 6b075c21b6
2 changed files with 11 additions and 9 deletions

View File

@@ -136,6 +136,16 @@ export const mapAlbum = (entity: AlbumEntity, withAssets: boolean, auth?: AuthDt
}
}
albumUsers.sort((a, b) => {
if (a.role === AlbumUserRole.VIEWER && b.role === AlbumUserRole.EDITOR) {
return 1;
}
if (a.role === AlbumUserRole.EDITOR && b.role === AlbumUserRole.VIEWER) {
return -1;
}
return a.user.name.localeCompare(b.user.name);
});
const assets = entity.assets || [];
const hasSharedLink = entity.sharedLinks?.length > 0;

View File

@@ -99,15 +99,7 @@
<p class="text-sm">Owner</p>
</div>
</div>
{#each album.albumUsers.toSorted((a, b) => {
if (a.role === AlbumUserRole.Viewer && b.role === AlbumUserRole.Editor) {
return 1;
}
if (a.role === AlbumUserRole.Editor && b.role === AlbumUserRole.Viewer) {
return -1;
}
return a.user.name.localeCompare(b.user.name);
}) as { user, role }}
{#each album.albumUsers as { user, role }}
<div
class="flex w-full place-items-center justify-between gap-4 p-5 rounded-xl transition-colors hover:bg-gray-50 dark:hover:bg-gray-700"
>