Adjust cursor tracking to new api

This commit is contained in:
Andras Schmelczer 2026-09-19 20:20:50 +01:00
commit 141db79f3a

View file

@ -138,7 +138,7 @@ export class CursorTracker {
const record = this.database.getLatestDocumentByRelativePath( const record = this.database.getLatestDocumentByRelativePath(
doc.relative_path doc.relative_path
); );
if (record?.metadata?.hash !== hash(readContent)) { if (record?.metadata?.hash !== (await hash(readContent))) {
doc.vault_update_id = null; doc.vault_update_id = null;
} }
} }
@ -178,6 +178,15 @@ export class CursorTracker {
result.push({ result.push({
...clientCursors, ...clientCursors,
documentsWithCursors: clientCursors.documentsWithCursors.map(
(document) => ({
...document,
relative_path:
this.database.getDocumentByDocumentId(
document.document_id
)?.relativePath ?? document.relative_path
})
),
isOutdated: isOutdated:
clientCursors.upToDateness === DocumentUpToDateness.Prior clientCursors.upToDateness === DocumentUpToDateness.Prior
}); });
@ -223,8 +232,8 @@ export class CursorTracker {
private async getDocumentUpToDateness( private async getDocumentUpToDateness(
document: DocumentWithCursors document: DocumentWithCursors
): Promise<DocumentUpToDateness> { ): Promise<DocumentUpToDateness> {
const record = this.database.getLatestDocumentByRelativePath( const record = this.database.getDocumentByDocumentId(
document.relative_path document.document_id
); );
if (!record) { if (!record) {
@ -245,13 +254,16 @@ export class CursorTracker {
return DocumentUpToDateness.Prior; return DocumentUpToDateness.Prior;
} }
const currentContent = await this.fileOperations.read( let currentContent: Uint8Array;
document.relative_path try {
currentContent = await this.fileOperations.read(
record.relativePath
); );
} catch {
return DocumentUpToDateness.Prior;
}
return this.database.getLatestDocumentByRelativePath( return record.metadata?.hash === (await hash(currentContent))
document.relative_path
)?.metadata?.hash === hash(currentContent)
? DocumentUpToDateness.UpToDate ? DocumentUpToDateness.UpToDate
: DocumentUpToDateness.Prior; : DocumentUpToDateness.Prior;
} }