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

View File

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