Disable background jobs on mobile

This commit is contained in:
Zef Hemel
2023-01-25 18:29:47 +01:00
parent ca8b8d9a84
commit bd152dd297
12 changed files with 139 additions and 101 deletions
+11 -1
View File
@@ -24,6 +24,7 @@ export class Space extends EventEmitter<SpaceEvents>
watchedPages = new Set<string>();
private initialPageListLoad = true;
private saving = false;
watchInterval?: number;
constructor(readonly spacePrimitives: SpacePrimitives) {
super();
@@ -89,7 +90,10 @@ export class Space extends EventEmitter<SpaceEvents>
}
watch() {
setInterval(() => {
if (this.watchInterval) {
clearInterval(this.watchInterval);
}
this.watchInterval = setInterval(() => {
safeRun(async () => {
if (this.saving) {
return;
@@ -109,6 +113,12 @@ export class Space extends EventEmitter<SpaceEvents>
this.updatePageList().catch(console.error);
}
unwatch() {
if (this.watchInterval) {
clearInterval(this.watchInterval);
}
}
async deletePage(name: string): Promise<void> {
await this.getPageMeta(name); // Check if page exists, if not throws Error
await this.spacePrimitives.deleteFile(`${name}.md`);
+3 -1
View File
@@ -357,7 +357,9 @@ export class SpaceSync {
}
syncCandidates(files: FileMeta[]): FileMeta[] {
return files.filter((f) => !f.name.startsWith("_plug/"));
return files.filter((f) =>
!f.name.startsWith("_plug/") && f.lastModified > 0
);
}
}