mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
docs(folders): fix the eight clunky ones
Two deleted outright: an upload branch and a folder lookup whose comments said what the condition below them said. The rest kept their fact and lost the rest of the sentence. DiskFileCard gets back the constraint that makes it unusual - no stub, so no selection or move. The "Local" tab keeps only the both-halves rule, not the predicate beside it. The disk-subfolder state says it is never persisted rather than restating its type. FolderRecord.kind pointed at folderKind twice over; now the accessor holds the rule and the field points at it.
This commit is contained in:
@@ -1647,7 +1647,10 @@ function FileRow({
|
||||
// Re-export root constant for caller convenience
|
||||
export { ROOT_FOLDER_ID };
|
||||
|
||||
/** A file listed straight off a mounted directory. */
|
||||
/**
|
||||
* No stub behind it, so no selection, move, rename or delete: the disk owns the
|
||||
* file and the only affordance is adding it to the workspace.
|
||||
*/
|
||||
function DiskFileCard({
|
||||
entry,
|
||||
onOpen,
|
||||
|
||||
@@ -322,7 +322,8 @@ export default function FileManagerView() {
|
||||
// Tab overrides folder navigation for Local/Recent/Shared.
|
||||
switch (currentTab) {
|
||||
case "local":
|
||||
// Local means no server copy AND no folder membership - not both places.
|
||||
// Both halves: a local file inside a browser folder belongs to that folder,
|
||||
// not here as well.
|
||||
return allFiles.filter(
|
||||
(f) => f.remoteStorageId == null && (f.folderId ?? null) === null,
|
||||
);
|
||||
@@ -452,7 +453,6 @@ export default function FileManagerView() {
|
||||
[foldersById],
|
||||
);
|
||||
|
||||
// Read-through: the directory is the source of truth, never ingested to show.
|
||||
const currentFolder = currentFolderId
|
||||
? folders.foldersById.get(currentFolderId)
|
||||
: undefined;
|
||||
@@ -694,7 +694,6 @@ export default function FileManagerView() {
|
||||
const target =
|
||||
currentTab === "all" || currentTab === "cloud" ? currentFolderId : null;
|
||||
const targetFolder = target ? folders.foldersById.get(target) : undefined;
|
||||
// A mount's upload writes straight to disk, never through app storage.
|
||||
if (targetFolder && folderKind(targetFolder) === "local") {
|
||||
const { failedCount } = await writeIntoMount(
|
||||
targetFolder.directory,
|
||||
|
||||
@@ -1500,12 +1500,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* A disabled destination in the New-folder menu still has to be READ — its
|
||||
* caption carries the reason it is disabled. Mantine's disabled colour sinks
|
||||
* below comfortable contrast (worst in dark mode), so the item keeps the
|
||||
* theme's muted/subtle text tones instead: visibly dimmer than an enabled
|
||||
* item, but legible. The dropdown renders in a portal, so the selector must
|
||||
* stand on the item's own class, not a page ancestor. */
|
||||
/* A disabled destination still has to be read - its caption carries the reason - and
|
||||
Mantine's disabled colour drops below comfortable contrast in dark mode. Selector
|
||||
stands on the item's own class because the dropdown renders in a portal. */
|
||||
.files-page-new-folder-option[data-disabled] {
|
||||
color: var(--c-text-muted) !important;
|
||||
opacity: 1;
|
||||
|
||||
@@ -280,7 +280,7 @@ function shouldStrandedReset(
|
||||
|
||||
export function FolderProvider({ children }: FolderProviderProps) {
|
||||
const [storedFolders, setFolders] = useState<FolderRecord[]>([]);
|
||||
// Subdirectories found inside mounts, keyed by parent. In memory only.
|
||||
// Never persisted: a directory is its own record, so a listing rebuilds these.
|
||||
const [diskSubfolders, setDiskSubfolders] = useState<
|
||||
Map<FolderId, FolderRecord[]>
|
||||
>(() => new Map());
|
||||
|
||||
@@ -82,10 +82,7 @@ export function useLazyThumbnail(
|
||||
return thumb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyed by path + mtime + size, so an unchanged file never renders twice and an edited
|
||||
* one does.
|
||||
*/
|
||||
// Keyed by path + mtime + size: an unchanged file never renders twice, an edited one does.
|
||||
const diskThumbCache = new Map<string, string>();
|
||||
// Bounded by bytes, not entries: image thumbnails are data URLs that track the
|
||||
// source, so 300 photos would pin gigabytes of strings for the process lifetime.
|
||||
|
||||
@@ -46,7 +46,7 @@ export type FolderKind = "server" | "virtual" | "local";
|
||||
/** Persisted folder shape stored in IndexedDB. */
|
||||
export interface FolderRecord {
|
||||
id: FolderId;
|
||||
/** Absent means `server`: rows predating kinds are all server folders. */
|
||||
/** Read through {@link folderKind}, never directly. */
|
||||
kind?: FolderKind;
|
||||
name: string;
|
||||
parentFolderId: FolderId | null;
|
||||
@@ -59,7 +59,7 @@ export interface FolderRecord {
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
/** The folder's kind. Absent means `server`: server DTOs and long-lived cached rows never carry one. */
|
||||
/** Absent means `server`: server DTOs and rows predating kinds never carry one. */
|
||||
export function folderKind(folder: Pick<FolderRecord, "kind">): FolderKind {
|
||||
return folder.kind ?? "server";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user