fix(library): sync React photos state after scan and support case-insensitive existing photo lookup
This commit is contained in:
@@ -724,7 +724,12 @@ export async function scanFolder(
|
||||
jump?: () => string | null,
|
||||
from = ''
|
||||
): Promise<ScanProgress> {
|
||||
const known = new Map((await listPhotos(folder.name)).map((p) => [p.id, p]));
|
||||
const rawKnown = await listPhotos(folder.name);
|
||||
const known = new Map<string, LibraryPhoto>();
|
||||
for (const p of rawKnown) {
|
||||
known.set(p.id, p);
|
||||
known.set(p.id.toLowerCase(), p);
|
||||
}
|
||||
// A reading kept to one folder keeps no position of its own. The position file
|
||||
// belongs to the reading that walks the whole roll, and a fraction of the tree
|
||||
// written into it would hand the next visit a roll with the rest of itself
|
||||
@@ -808,9 +813,17 @@ export async function scanFolder(
|
||||
counts[key.toLowerCase()] = counts[key];
|
||||
}
|
||||
};
|
||||
for (const id of known.keys()) count(id.startsWith(`${normRoot}/`) ? id.slice(normRoot.length + 1) : id);
|
||||
const relOfId = (id: string) => {
|
||||
const normId = normPath(id);
|
||||
const prefix = `${normRoot}/`.toLowerCase();
|
||||
if (normId.toLowerCase().startsWith(prefix)) {
|
||||
return normId.slice(normRoot.length + 1);
|
||||
}
|
||||
return normId;
|
||||
};
|
||||
for (const id of known.keys()) count(relOfId(id));
|
||||
const knownPaths = new Set(
|
||||
[...known.keys()].map((id) => (id.startsWith(`${normRoot}/`) ? id.slice(normRoot.length + 1) : id))
|
||||
[...known.keys()].map((id) => relOfId(id))
|
||||
);
|
||||
const countedDiscovered = new Set<string>();
|
||||
const countDiscovered = (rel: string) => {
|
||||
@@ -825,8 +838,9 @@ export async function scanFolder(
|
||||
// been read once before is a reading of a hundred thousand frames even while
|
||||
// the walk is still up in its first folders, and one kept to a subfolder is
|
||||
// measured against the frames under that one alone.
|
||||
const heldPrefix = `${folder.name}/${from}`.toLowerCase();
|
||||
const held = bounded
|
||||
? [...known.keys()].filter((id) => id.startsWith(`${folder.name}/${from}`)).length
|
||||
? [...known.keys()].filter((id) => id.toLowerCase().startsWith(heldPrefix)).length
|
||||
: known.size;
|
||||
// What the screen is told, and how often. The column is redrawn out of the
|
||||
// count and the count moves with every frame, so telling the screen a frame at
|
||||
|
||||
Reference in New Issue
Block a user