Fix regression where the index would no longer be cleared in sync mode

pull/893/head
Zef Hemel 2024-06-13 11:46:52 +02:00
parent 0e2553839c
commit 78be20c24f
2 changed files with 10 additions and 10 deletions

View File

@ -117,6 +117,7 @@ export class EventedSpacePrimitives implements SpacePrimitives {
async writeFile(
name: string,
data: Uint8Array,
// TODO: Is self update still used or can it now be removed?
selfUpdate?: boolean,
meta?: FileMeta,
): Promise<FileMeta> {
@ -128,15 +129,13 @@ export class EventedSpacePrimitives implements SpacePrimitives {
selfUpdate,
meta,
);
if (!selfUpdate) {
await this.dispatchEvent(
"file:changed",
name,
true,
undefined,
newMeta.lastModified,
);
}
await this.dispatchEvent(
"file:changed",
name,
true,
undefined,
newMeta.lastModified,
);
this.spaceSnapshot[name] = newMeta.lastModified;
if (name.endsWith(".md")) {

View File

@ -599,12 +599,13 @@ export class Client {
"file:changed",
(
path: string,
_localChange: boolean,
localChange: boolean,
oldHash: number,
newHash: number,
) => {
// Only reload when watching the current page (to avoid reloading when switching pages)
if (
!localChange &&
this.space.watchInterval && `${this.currentPage}.md` === path &&
// Avoid reloading if the page was just saved (5s window)
(!lastSaveTimestamp || (lastSaveTimestamp < Date.now() - 5000))