Extract event handlers

This commit is contained in:
Andras Schmelczer 2024-12-10 22:24:31 +00:00
parent 0c3e74e2b8
commit 5f1075879f
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 130 additions and 61 deletions

View 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);
}