Adding some page reload debugging

This commit is contained in:
Zef Hemel
2023-11-12 10:33:27 +01:00
parent 51e3dd72e8
commit bedc85e7a9
3 changed files with 26 additions and 14 deletions
+23 -10
View File
@@ -389,16 +389,29 @@ export class Client {
this.eventHook,
);
this.eventHook.addLocalListener("file:changed", (path: string) => {
// Only reload when watching the current page (to avoid reloading when switching pages)
if (
this.space.watchInterval && `${this.currentPage}.md` === path
) {
console.log("Page changed elsewhere, reloading");
this.flashNotification("Page changed elsewhere, reloading");
this.reloadPage();
}
});
this.eventHook.addLocalListener(
"file:changed",
(
path: string,
_localChange?: boolean,
oldHash?: number,
newHash?: number,
) => {
// Only reload when watching the current page (to avoid reloading when switching pages)
if (
this.space.watchInterval && `${this.currentPage}.md` === path
) {
console.log(
"Page changed elsewhere, reloading. Old hash",
oldHash,
"new hash",
newHash,
);
this.flashNotification("Page changed elsewhere, reloading");
this.reloadPage();
}
},
);
this.eventHook.addLocalListener("file:listed", (fileList: FileMeta[]) => {
this.ui.viewDispatch({