Rename
This commit is contained in:
parent
8cdad79160
commit
c250e82998
1 changed files with 3 additions and 2 deletions
14
frontend/sync-client/src/utils/find-matching-file.ts
Normal file
14
frontend/sync-client/src/utils/find-matching-file.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import type { DocumentMetadata, RelativePath } from "../persistence/database";
|
||||||
|
import { EMPTY_HASH } from "./hash";
|
||||||
|
|
||||||
|
// TODO: make this smarter so that offline files can be renamed & edited at the same time
|
||||||
|
export function findMatchingFile(
|
||||||
|
contentHash: string,
|
||||||
|
candidates: [RelativePath, DocumentMetadata][]
|
||||||
|
): [RelativePath, DocumentMetadata] | undefined {
|
||||||
|
if (contentHash === EMPTY_HASH) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidates.find(([_, metadata]) => metadata.hash === contentHash);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue