Extract event handlers
This commit is contained in:
parent
0c3e74e2b8
commit
5f1075879f
5 changed files with 130 additions and 61 deletions
22
plugin/src/sync-functions/sync-locally-deleted-file.ts
Normal file
22
plugin/src/sync-functions/sync-locally-deleted-file.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { TFile } from "obsidian";
|
||||
import { Database } from "src/database/database";
|
||||
import { RelativePath } from "src/database/document-metadata";
|
||||
import { SyncServer } from "src/services/sync_service";
|
||||
|
||||
export async function syncLocallyDeletedFile(
|
||||
database: Database,
|
||||
syncServer: SyncServer,
|
||||
path: RelativePath
|
||||
) {
|
||||
const metadata = database.getDocument(path);
|
||||
if (!metadata) {
|
||||
throw `Document metadata not found for ${path}`;
|
||||
}
|
||||
|
||||
await syncServer.delete({
|
||||
documentId: metadata.documentId,
|
||||
createdDate: new Date(), // We got the event now, so it must have been deleted now
|
||||
});
|
||||
|
||||
await database.removeDocument(path);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue