mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2024-12-12 09:04:06 +02:00
fixed some base on awsome advices.
- do not show too frequent message. - fixing code mistake
This commit is contained in:
parent
f3f0639d95
commit
57187a0926
4
.gitignore
vendored
4
.gitignore
vendored
@ -7,8 +7,8 @@ node_modules
|
||||
package-lock.json
|
||||
|
||||
# build
|
||||
# main.js
|
||||
main.js
|
||||
*.js.map
|
||||
|
||||
# obsidian
|
||||
data.json
|
||||
data.json
|
||||
|
32
main.ts
32
main.ts
@ -342,7 +342,7 @@ class LocalPouchDB {
|
||||
// console.log(nleafid);
|
||||
let pieceData = await this.localDatabase.get<EntryLeaf>(nleafid);
|
||||
if (pieceData.type == "leaf" && pieceData.data == piece) {
|
||||
this.addLog("hashe:data exists.");
|
||||
this.addLog("hash:data exists.");
|
||||
leafid = nleafid;
|
||||
needMake = false;
|
||||
tryNextHash = false;
|
||||
@ -425,7 +425,7 @@ class LocalPouchDB {
|
||||
password: setting.couchDB_PASSWORD,
|
||||
};
|
||||
if (this.syncHandler != null) {
|
||||
this.addLog("Another replication running.", true);
|
||||
this.addLog("Another replication running.");
|
||||
return false;
|
||||
}
|
||||
let dbret = await connectRemoteCouchDB(uri, auth);
|
||||
@ -601,6 +601,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
||||
this.addLog("loading plugin");
|
||||
await this.openDatabase();
|
||||
await this.loadSettings();
|
||||
|
||||
addIcon(
|
||||
"replicate",
|
||||
`<g transform="matrix(1.15 0 0 1.15 -8.31 -9.52)" fill="currentColor" fill-rule="evenodd">
|
||||
@ -640,13 +641,13 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
||||
|
||||
this.addSettingTab(new ObsidianLiveSyncSettingTab(this.app, this));
|
||||
|
||||
setTimeout(async () => {
|
||||
this.app.workspace.onLayoutReady(async () => {
|
||||
await this.initializeDatabase();
|
||||
this.realizeSettingSyncMode();
|
||||
if (this.settings.syncOnStart) {
|
||||
await this.replicate(false);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
// when in mobile, too long suspended , connection won't back if setting retry:true
|
||||
this.registerInterval(
|
||||
@ -662,7 +663,6 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
||||
this.watchWindowVisiblity = this.watchWindowVisiblity.bind(this);
|
||||
window.addEventListener("visibilitychange", this.watchWindowVisiblity);
|
||||
}
|
||||
|
||||
onunload() {
|
||||
if (this.gcTimerHandler != null) {
|
||||
clearTimeout(this.gcTimerHandler);
|
||||
@ -971,7 +971,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
||||
let entry = v as TFile & TFolder;
|
||||
if (entry.children) {
|
||||
await this.deleteFolderOnDB(entry);
|
||||
this.app.vault.delete(entry);
|
||||
await this.app.vault.delete(entry);
|
||||
} else {
|
||||
await this.deleteFromDB(entry);
|
||||
}
|
||||
@ -1418,6 +1418,18 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
//await this.test();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName("Re-init")
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText("Init Database again")
|
||||
.setDisabled(false)
|
||||
.onClick(async () => {
|
||||
await this.plugin.resetLocalDatabase();
|
||||
await this.plugin.initializeDatabase();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Garbage Collect")
|
||||
.addButton((button) =>
|
||||
@ -1429,14 +1441,6 @@ class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
//await this.test();
|
||||
})
|
||||
)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText("Reset local files")
|
||||
.setDisabled(false)
|
||||
.onClick(async () => {
|
||||
//await this.test();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl).setName("Remote Database Operations").addButton((button) =>
|
||||
button
|
||||
.setButtonText("Reset remote database")
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-livesync",
|
||||
"name": "Obsidian Live sync",
|
||||
"version": "0.0.8",
|
||||
"version": "0.0.9",
|
||||
"minAppVersion": "0.9.12",
|
||||
"description": "obsidian Live synchronization plugin.",
|
||||
"author": "vorotamoroz",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "obsidian-livesync",
|
||||
"version": "0.0.8",
|
||||
"version": "0.0.9",
|
||||
"description": "obsidian Live synchronization plugin.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user