mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2024-12-12 09:04:06 +02:00
Fixed
- Fix file extension - Remove GC. - Remove obsoluted methods.
This commit is contained in:
parent
de5cdf507d
commit
34791114e5
@ -1,12 +1,12 @@
|
|||||||
import { requestUrl, RequestUrlParam, RequestUrlResponse } from "obsidian";
|
import { requestUrl, RequestUrlParam, RequestUrlResponse } from "obsidian";
|
||||||
import { KeyValueDatabase, OpenKeyValueDatabase } from "./KeyValueDB";
|
import { KeyValueDatabase, OpenKeyValueDatabase } from "./KeyValueDB.js";
|
||||||
import { LocalPouchDBBase } from "./lib/src/LocalPouchDBBase";
|
import { LocalPouchDBBase } from "./lib/src/LocalPouchDBBase.js";
|
||||||
import { Logger } from "./lib/src/logger";
|
import { Logger } from "./lib/src/logger.js";
|
||||||
import { PouchDB } from "./lib/src/pouchdb-browser";
|
import { PouchDB } from "./lib/src/pouchdb-browser.js";
|
||||||
import { EntryDoc, LOG_LEVEL } from "./lib/src/types";
|
import { EntryDoc, LOG_LEVEL } from "./lib/src/types.js";
|
||||||
import { enableEncryption } from "./lib/src/utils";
|
import { enableEncryption } from "./lib/src/utils.js";
|
||||||
import { isValidRemoteCouchDBURI } from "./lib/src/utils_couchdb";
|
import { isValidRemoteCouchDBURI } from "./lib/src/utils_couchdb.js";
|
||||||
import { id2path, path2id } from "./utils";
|
import { id2path, path2id } from "./utils.js";
|
||||||
|
|
||||||
export class LocalPouchDB extends LocalPouchDBBase {
|
export class LocalPouchDB extends LocalPouchDBBase {
|
||||||
|
|
||||||
|
2
src/lib
2
src/lib
@ -1 +1 @@
|
|||||||
Subproject commit 57db68352b7d891a29529eb2b26ef4fcbb29bc76
|
Subproject commit 2c39c1517765c2bbc8da9c203313cd606407ce72
|
31
src/main.ts
31
src/main.ts
@ -462,13 +462,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
await this.showIfConflicted(view.file);
|
await this.showIfConflicted(view.file);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.addCommand({
|
|
||||||
id: "livesync-gc",
|
|
||||||
name: "Check garbages now",
|
|
||||||
callback: () => {
|
|
||||||
this.garbageCheck();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
id: "livesync-toggle",
|
id: "livesync-toggle",
|
||||||
name: "Toggle LiveSync",
|
name: "Toggle LiveSync",
|
||||||
@ -614,9 +608,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
return await this.localDatabase.initializeDatabase();
|
return await this.localDatabase.initializeDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
async garbageCheck() {
|
|
||||||
await this.localDatabase.garbageCheck();
|
|
||||||
}
|
|
||||||
|
|
||||||
async loadSettings() {
|
async loadSettings() {
|
||||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||||
@ -656,19 +647,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
|
|
||||||
gcTimerHandler: any = null;
|
gcTimerHandler: any = null;
|
||||||
|
|
||||||
gcHook() {
|
|
||||||
if (this.settings.gcDelay == 0) return;
|
|
||||||
if (this.settings.useHistory) return;
|
|
||||||
const GC_DELAY = this.settings.gcDelay * 1000; // if leaving opening window, try GC,
|
|
||||||
if (this.gcTimerHandler != null) {
|
|
||||||
clearTimeout(this.gcTimerHandler);
|
|
||||||
this.gcTimerHandler = null;
|
|
||||||
}
|
|
||||||
this.gcTimerHandler = setTimeout(() => {
|
|
||||||
this.gcTimerHandler = null;
|
|
||||||
this.garbageCheck();
|
|
||||||
}, GC_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerWatchEvents() {
|
registerWatchEvents() {
|
||||||
this.registerEvent(this.app.vault.on("modify", this.watchVaultChange));
|
this.registerEvent(this.app.vault.on("modify", this.watchVaultChange));
|
||||||
@ -719,7 +697,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
this.setPeriodicSync();
|
this.setPeriodicSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.gcHook();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watchWorkspaceOpen(file: TFile) {
|
watchWorkspaceOpen(file: TFile) {
|
||||||
@ -736,7 +713,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
await this.replicate();
|
await this.replicate();
|
||||||
}
|
}
|
||||||
await this.showIfConflicted(file);
|
await this.showIfConflicted(file);
|
||||||
this.gcHook();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watchVaultCreate(file: TFile, ...args: any[]) {
|
watchVaultCreate(file: TFile, ...args: any[]) {
|
||||||
@ -816,7 +792,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.updateIntoDB(file);
|
await this.updateIntoDB(file);
|
||||||
this.gcHook();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -834,7 +809,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
} else if (file instanceof TFolder) {
|
} else if (file instanceof TFolder) {
|
||||||
await this.deleteFolderOnDB(file);
|
await this.deleteFolderOnDB(file);
|
||||||
}
|
}
|
||||||
this.gcHook();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetAllFilesRecursively(file: TAbstractFile): TFile[] {
|
GetAllFilesRecursively(file: TAbstractFile): TFile[] {
|
||||||
@ -904,7 +878,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
Logger(ex);
|
Logger(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.gcHook();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addLogHook: () => void = null;
|
addLogHook: () => void = null;
|
||||||
@ -1352,7 +1325,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
Logger(`Remote database updated to incompatible version. update your self-hosted-livesync plugin.`, LOG_LEVEL.NOTICE);
|
Logger(`Remote database updated to incompatible version. update your self-hosted-livesync plugin.`, LOG_LEVEL.NOTICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.gcHook();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2077,6 +2049,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
async resetLocalDatabase() {
|
async resetLocalDatabase() {
|
||||||
clearTouched();
|
clearTouched();
|
||||||
await this.localDatabase.resetDatabase();
|
await this.localDatabase.resetDatabase();
|
||||||
|
await this.localDatabase.resetLocalOldDatabase();
|
||||||
}
|
}
|
||||||
async resetLocalOldDatabase() {
|
async resetLocalOldDatabase() {
|
||||||
clearTouched();
|
clearTouched();
|
||||||
|
Loading…
Reference in New Issue
Block a user