fix(frontend): sort a file's assigned tags by the chosen tag order
The file viewer's assigned-tags list showed tags in API order, ignoring the sort the user picked on the tags page. Add a client-side sortTags helper and order the assigned list (in TagPicker) by tagSorting, reactively so it re-sorts the moment the sort changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import type { Tag } from '$lib/api/types';
|
||||
import { fetchAllTags } from '$lib/api/tags';
|
||||
import { fetchAllTags, sortTags } from '$lib/api/tags';
|
||||
import { tagSorting } from '$lib/stores/sorting';
|
||||
|
||||
interface Props {
|
||||
fileTags: Tag[];
|
||||
@@ -30,10 +31,13 @@
|
||||
)
|
||||
);
|
||||
|
||||
// Show a file's already-assigned tags in the user's chosen tag order too.
|
||||
let sortedAssigned = $derived(sortTags(fileTags, $tagSorting));
|
||||
|
||||
let filteredAssigned = $derived(
|
||||
search.trim()
|
||||
? fileTags.filter((t) => t.name?.toLowerCase().includes(search.toLowerCase()))
|
||||
: fileTags
|
||||
? sortedAssigned.filter((t) => t.name?.toLowerCase().includes(search.toLowerCase()))
|
||||
: sortedAssigned
|
||||
);
|
||||
|
||||
async function handleAdd(tagId: string) {
|
||||
|
||||
Reference in New Issue
Block a user