refactor(front): apply formatter
This commit is contained in:
@@ -695,7 +695,12 @@
|
|||||||
const bandBottom = bandTop + rubberband.h;
|
const bandBottom = bandTop + rubberband.h;
|
||||||
|
|
||||||
const rows = rlRoot.querySelectorAll<HTMLElement>('.file-item[data-item-id]');
|
const rows = rlRoot.querySelectorAll<HTMLElement>('.file-item[data-item-id]');
|
||||||
const nextSelection = new Set(rubberband.baseline);
|
// Transient scratch set for computing the diff before mutating
|
||||||
|
// `selected`. `SvelteSet` (not plain `Set`) per the codebase's
|
||||||
|
// `svelte/prefer-svelte-reactivity` convention — the lint rule
|
||||||
|
// exists so a future refactor that stashes this in `$state`
|
||||||
|
// can't silently break reactivity.
|
||||||
|
const nextSelection = new SvelteSet(rubberband.baseline);
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const id = row.dataset.itemId;
|
const id = row.dataset.itemId;
|
||||||
if (!id) continue;
|
if (!id) continue;
|
||||||
@@ -1245,7 +1250,8 @@
|
|||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></div>
|
></div>
|
||||||
{/if}
|
{/if}
|
||||||
</div><!-- /.rl-root -->
|
</div>
|
||||||
|
<!-- /.rl-root -->
|
||||||
|
|
||||||
{#snippet listHeader()}
|
{#snippet listHeader()}
|
||||||
<div class="list-header">
|
<div class="list-header">
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import SkeletonList from '$lib/components/SkeletonList.svelte';
|
|
||||||
import EmptyState from '$lib/components/EmptyState.svelte';
|
|
||||||
import { errorMessage, errorToast } from '$lib/utils/errors';
|
import { errorMessage, errorToast } from '$lib/utils/errors';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
@@ -25,10 +23,8 @@
|
|||||||
import {
|
import {
|
||||||
deleteFile,
|
deleteFile,
|
||||||
fileDownloadUrl,
|
fileDownloadUrl,
|
||||||
fileThumbnailUrl,
|
|
||||||
moveFile,
|
moveFile,
|
||||||
renameFile,
|
renameFile,
|
||||||
thumbSizeForView,
|
|
||||||
uploadFileWithProgress
|
uploadFileWithProgress
|
||||||
} from '$lib/api/endpoints/files';
|
} from '$lib/api/endpoints/files';
|
||||||
import { folderZipUrl } from '$lib/api/endpoints/folders';
|
import { folderZipUrl } from '$lib/api/endpoints/folders';
|
||||||
@@ -850,23 +846,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the server can render a thumbnail preview for this file. Only images
|
|
||||||
* and videos have server-side thumbnails (see `ThumbnailService::is_supported_image`
|
|
||||||
* plus client-uploaded video frames); the backend does NOT rasterise PDFs or
|
|
||||||
* documents, so claiming it could left their tiles blank (the doomed <img>
|
|
||||||
* 404s and `onerror` hides it). Non-thumbnail files fall back to their colour
|
|
||||||
* type icon, which renders underneath the <img> regardless.
|
|
||||||
*/
|
|
||||||
function canThumbnail(file: FileItem): boolean {
|
|
||||||
const m = file.mime_type ?? '';
|
|
||||||
// PDF joins image/video: the client-side generator ported from
|
|
||||||
// the legacy vanilla frontend renders PDFs via pdf.js on the
|
|
||||||
// `<img onerror>` fallback path. Without this the img never
|
|
||||||
// mounts for PDFs and the fallback never fires.
|
|
||||||
return m.startsWith('image/') || m.startsWith('video/') || m === 'application/pdf';
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Multi-select + batch ────────────────────────────────────────────────
|
// ── Multi-select + batch ────────────────────────────────────────────────
|
||||||
// After the ResourceList migration the row-level selection UX (shift-
|
// After the ResourceList migration the row-level selection UX (shift-
|
||||||
// range, ctrl-toggle, anchor tracking, header select-all) lives inside
|
// range, ctrl-toggle, anchor tracking, header select-all) lives inside
|
||||||
@@ -1390,26 +1369,20 @@
|
|||||||
input.value = '';
|
input.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visual emptiness — reflects the filtered set, not the raw listing.
|
|
||||||
// When the folder contains only dotfiles that the user has chosen to
|
|
||||||
// hide, `visibleFolders + visibleFiles` is empty and the empty state
|
|
||||||
// renders; `hiddenCount` above lets the template surface a "you're
|
|
||||||
// hiding N items" hint so users aren't confused.
|
|
||||||
const isEmpty = $derived(visibleFolders.length === 0 && visibleFiles.length === 0);
|
|
||||||
|
|
||||||
// Client-side sort (flat, Drive-style). The listing endpoint returns the
|
// Client-side sort (flat, Drive-style). The listing endpoint returns the
|
||||||
// folder contents unsorted; sorting here avoids a refetch per column click.
|
// folder contents unsorted; sorting here avoids a refetch per column click.
|
||||||
|
//
|
||||||
|
// `reversed` is the single source of truth for direction — bound to
|
||||||
|
// ResourceList's `bind:reversed` below and read by the comparators.
|
||||||
|
// The legacy `sortDir: 1 | -1` value used by the comparators is a
|
||||||
|
// read-only `$derived` off `reversed` so we don't need two-way sync
|
||||||
|
// (the previous `$state` + two `$effect` mirror was fragile — a
|
||||||
|
// programmatic write to either side triggered an update on the
|
||||||
|
// other, and eslint's `prefer-writable-derived` rightly flagged it).
|
||||||
type SortField = 'name' | 'type' | 'size' | 'modified_at' | 'created_at';
|
type SortField = 'name' | 'type' | 'size' | 'modified_at' | 'created_at';
|
||||||
let sortField = $state<SortField>('name');
|
let sortField = $state<SortField>('name');
|
||||||
let sortDir = $state<1 | -1>(1);
|
let reversed = $state(false);
|
||||||
|
const sortDir = $derived<1 | -1>(reversed ? -1 : 1);
|
||||||
function toggleSort(field: SortField) {
|
|
||||||
if (sortField === field) sortDir = (sortDir * -1) as 1 | -1;
|
|
||||||
else {
|
|
||||||
sortField = field;
|
|
||||||
sortDir = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cmpFolders(a: FolderItem, b: FolderItem): number {
|
function cmpFolders(a: FolderItem, b: FolderItem): number {
|
||||||
let v: number;
|
let v: number;
|
||||||
@@ -1485,18 +1458,6 @@
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ResourceList's `reversed` is a boolean; the legacy sort uses `1 | -1`.
|
|
||||||
// Two-way binding: setting `rlReversed` writes back into `sortDir`, and
|
|
||||||
// any programmatic sort direction change (e.g. group-by picking) mirrors
|
|
||||||
// out.
|
|
||||||
let rlReversed = $state(false);
|
|
||||||
$effect(() => {
|
|
||||||
rlReversed = sortDir === -1;
|
|
||||||
});
|
|
||||||
$effect(() => {
|
|
||||||
sortDir = rlReversed ? -1 : 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Bridge for <ResourceList>'s callbacks — the row's open/favorite/drag
|
// Bridge for <ResourceList>'s callbacks — the row's open/favorite/drag
|
||||||
// props take one item; the legacy handlers take `(kind, id, name)`.
|
// props take one item; the legacy handlers take `(kind, id, name)`.
|
||||||
function rlOnOpen(item: FileItem | FolderItem) {
|
function rlOnOpen(item: FileItem | FolderItem) {
|
||||||
@@ -1547,8 +1508,6 @@
|
|||||||
return () => window.removeEventListener('pointerdown', onDown);
|
return () => window.removeEventListener('pointerdown', onDown);
|
||||||
});
|
});
|
||||||
|
|
||||||
const SKELETON = [0, 1, 2, 3, 4, 5, 6, 7];
|
|
||||||
|
|
||||||
// Reload whenever the route path changes.
|
// Reload whenever the route path changes.
|
||||||
//
|
//
|
||||||
// `load()` reads several reactive signals in its sync phase
|
// `load()` reads several reactive signals in its sync phase
|
||||||
@@ -1640,7 +1599,7 @@
|
|||||||
onsystemdrop={onDrop}
|
onsystemdrop={onDrop}
|
||||||
groupBys={rlGroupBys}
|
groupBys={rlGroupBys}
|
||||||
bind:groupBy
|
bind:groupBy
|
||||||
bind:reversed={rlReversed}
|
bind:reversed
|
||||||
onreload={(orderBy) => {
|
onreload={(orderBy) => {
|
||||||
sortField = orderBy as SortField;
|
sortField = orderBy as SortField;
|
||||||
}}
|
}}
|
||||||
@@ -1735,17 +1694,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button class="btn btn-secondary" data-testid="files-new-folder-btn" onclick={onNewFolder}>
|
||||||
class="btn btn-secondary"
|
|
||||||
data-testid="files-new-folder-btn"
|
|
||||||
onclick={onNewFolder}
|
|
||||||
>
|
|
||||||
<Icon name="folder-plus" class="icon-mr" />
|
<Icon name="folder-plus" class="icon-mr" />
|
||||||
<span>{t('actions.new_folder', 'New folder')}</span>
|
<span>{t('actions.new_folder', 'New folder')}</span>
|
||||||
</button>
|
</button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
{#snippet batchActions(sel)}
|
{#snippet batchActions(_sel)}
|
||||||
<button
|
<button
|
||||||
class="batch-btn"
|
class="batch-btn"
|
||||||
title={t('files.add_favorites', 'Add to favorites')}
|
title={t('files.add_favorites', 'Add to favorites')}
|
||||||
|
|||||||
Reference in New Issue
Block a user