diff --git a/common/spaces/evented_space_primitives.ts b/common/spaces/evented_space_primitives.ts index 7e82f098..70babd48 100644 --- a/common/spaces/evented_space_primitives.ts +++ b/common/spaces/evented_space_primitives.ts @@ -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 { @@ -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")) { diff --git a/web/client.ts b/web/client.ts index 935e65e1..f1027185 100644 --- a/web/client.ts +++ b/web/client.ts @@ -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))