feat(user-pref): revert view mode as user-prefs serverside

previous change is breaking playwright tests, need to check later changes
This commit is contained in:
Edouard Vanbelle
2026-07-13 23:16:04 +02:00
parent b18f0dc74a
commit b9d6fa39c0
8 changed files with 57 additions and 54 deletions
@@ -1366,7 +1366,7 @@
// hiding N items" hint so users aren't confused.
const isEmpty = $derived(visibleFolders.length === 0 && visibleFiles.length === 0);
const viewClass = $derived(
preferences.viewMode === 'grid' ? 'files-grid-view' : 'files-list-view'
filesStore.viewMode === 'grid' ? 'files-grid-view' : 'files-list-view'
);
// Client-side sort (flat, Drive-style). The listing endpoint returns the
@@ -1806,7 +1806,7 @@
{/each}
{/each}
</div>
{:else if preferences.viewMode === 'list'}
{:else if filesStore.viewMode === 'list'}
<!-- Flat list: only the rows near the viewport are mounted. -->
<div class="files-list-view">
{@render fileListHeader()}
+2 -7
View File
@@ -62,7 +62,7 @@ vi.mock('$lib/api/endpoints/folders', () => ({
import { fetchFolderListing, createFolder, deleteFolder } from '$lib/api/endpoints/folders';
import { deleteFile } from '$lib/api/endpoints/files';
import { apiFetch } from '$lib/api/client';
import { preferences } from '$lib/stores/preferences.svelte';
import { files as filesStore } from '$lib/stores/files.svelte';
import FilesPage from './[...path]/+page.svelte';
const m = (fn: unknown) => fn as ReturnType<typeof vi.fn>;
@@ -126,12 +126,7 @@ beforeEach(() => {
// listing-oriented tests target a folder directly.
pageState.params.path = 'home';
// List view renders the select-all header + per-row checkboxes; grid hides them.
// The store's `setViewMode` writes through to the server bag via a
// debounced PATCH; in the test harness there's no session so the
// PATCH silently no-ops on the network side but the optimistic local
// mutation (session.user.ui_preferences.view_mode) still lands and
// downstream `preferences.viewMode` re-derives to 'list'.
preferences.setViewMode('list');
filesStore.viewMode = 'list';
});
it('loads the home folder listing on mount and renders its contents', async () => {