mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-01-23 13:37:11 +00:00
Fixed
- Vault History can show the correct information of match-or-not for each file and database even if it is a binary file.
- `Sync settings via markdown` is now hidden during the setup wizard.
- Verify and Fix will ignore the hidden files if the hidden file sync is disabled.
New feature
- Now we can fetch the tweaks from the remote database while the setting dialogue and wizard are processing.
Improved
- More things are moved to the modules.
- Includes the Main codebase. Now `main.ts` is almost stub.
- EventHub is now more robust and typesafe.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
import { diff_match_patch } from "../../../deps.ts";
|
||||
import { DocumentHistoryModal } from "../DocumentHistory/DocumentHistoryModal.ts";
|
||||
import { isPlainText, stripAllPrefixes } from "../../../lib/src/string_and_binary/path.ts";
|
||||
import { TFile } from "../../../deps.ts";
|
||||
import { getPath } from "../../../common/utils.ts";
|
||||
export let plugin: ObsidianLiveSyncPlugin;
|
||||
|
||||
@@ -105,9 +104,9 @@
|
||||
}
|
||||
if (rev == docA._rev) {
|
||||
if (checkStorageDiff) {
|
||||
const isExist = await plugin.storageAccess.isExists(stripAllPrefixes(getPath(docA)));
|
||||
const isExist = await plugin.storageAccess.isExistsIncludeHidden(stripAllPrefixes(getPath(docA)));
|
||||
if (isExist) {
|
||||
const data = await plugin.storageAccess.readFileAuto(stripAllPrefixes(getPath(docA)));
|
||||
const data = await plugin.storageAccess.readHiddenFileBinary(stripAllPrefixes(getPath(docA)));
|
||||
const d = readAsBlob(doc);
|
||||
const result = await isDocContentSame(data, d);
|
||||
if (result) {
|
||||
|
||||
@@ -72,7 +72,7 @@ export class ModuleInteractiveConflictResolver extends AbstractObsidianModule im
|
||||
// In here, some merge has been processed.
|
||||
// So we have to run replication if configured.
|
||||
// TODO: Make this is as a event request
|
||||
if (this.settings.syncAfterMerge && !this.plugin.suspended) {
|
||||
if (this.settings.syncAfterMerge && !this.core.$$isSuspended()) {
|
||||
await this.core.$$waitForReplicationOnce();
|
||||
}
|
||||
// And, check it again.
|
||||
@@ -96,7 +96,7 @@ export class ModuleInteractiveConflictResolver extends AbstractObsidianModule im
|
||||
this._log("There are no conflicted documents", LOG_LEVEL_NOTICE);
|
||||
return false;
|
||||
}
|
||||
const target = await this.plugin.confirm.askSelectString("File to resolve conflict", notesList);
|
||||
const target = await this.core.confirm.askSelectString("File to resolve conflict", notesList);
|
||||
if (target) {
|
||||
const targetItem = notes.find(e => e.dispPath == target)!;
|
||||
await this.core.$$queueConflictCheck(targetItem.path);
|
||||
@@ -114,7 +114,7 @@ export class ModuleInteractiveConflictResolver extends AbstractObsidianModule im
|
||||
notes.push({ path: getPath(doc), mtime: doc.mtime });
|
||||
}
|
||||
if (notes.length > 0) {
|
||||
this.plugin.confirm.askInPopup(`conflicting-detected-on-safety`, `Some files have been left conflicted! Press {HERE} to resolve them, or you can do it later by "Pick a file to resolve conflict`, (anchor) => {
|
||||
this.core.confirm.askInPopup(`conflicting-detected-on-safety`, `Some files have been left conflicted! Press {HERE} to resolve them, or you can do it later by "Pick a file to resolve conflict`, (anchor) => {
|
||||
anchor.text = "HERE";
|
||||
anchor.addEventListener("click", () => {
|
||||
fireAndForget(() => this.allConflictCheck())
|
||||
|
||||
@@ -67,12 +67,12 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
})
|
||||
return computed(() => formatted.value);
|
||||
}
|
||||
const labelReplication = padLeftSpComputed(this.plugin.replicationResultCount, `📥`);
|
||||
const labelDBCount = padLeftSpComputed(this.plugin.databaseQueueCount, `📄`);
|
||||
const labelStorageCount = padLeftSpComputed(this.plugin.storageApplyingCount, `💾`);
|
||||
const labelReplication = padLeftSpComputed(this.core.replicationResultCount, `📥`);
|
||||
const labelDBCount = padLeftSpComputed(this.core.databaseQueueCount, `📄`);
|
||||
const labelStorageCount = padLeftSpComputed(this.core.storageApplyingCount, `💾`);
|
||||
const labelChunkCount = padLeftSpComputed(collectingChunks, `🧩`);
|
||||
const labelPluginScanCount = padLeftSpComputed(pluginScanningCount, `🔌`);
|
||||
const labelConflictProcessCount = padLeftSpComputed(this.plugin.conflictProcessQueueCount, `🔩`);
|
||||
const labelConflictProcessCount = padLeftSpComputed(this.core.conflictProcessQueueCount, `🔩`);
|
||||
const hiddenFilesCount = reactive(() => hiddenFilesEventCount.value + hiddenFilesProcessingCount.value);
|
||||
const labelHiddenFilesCount = padLeftSpComputed(hiddenFilesCount, `⚙️`)
|
||||
const queueCountLabelX = reactive(() => {
|
||||
@@ -81,12 +81,12 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
const queueCountLabel = () => queueCountLabelX.value;
|
||||
|
||||
const requestingStatLabel = computed(() => {
|
||||
const diff = this.plugin.requestCount.value - this.plugin.responseCount.value;
|
||||
const diff = this.core.requestCount.value - this.core.responseCount.value;
|
||||
return diff != 0 ? "📲 " : "";
|
||||
})
|
||||
|
||||
const replicationStatLabel = computed(() => {
|
||||
const e = this.plugin.replicationStat.value;
|
||||
const e = this.core.replicationStat.value;
|
||||
const sent = e.sent;
|
||||
const arrived = e.arrived;
|
||||
const maxPullSeq = e.maxPullSeq;
|
||||
@@ -128,9 +128,9 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
}
|
||||
return { w, sent, pushLast, arrived, pullLast };
|
||||
})
|
||||
const labelProc = padLeftSpComputed(this.plugin.processing, `⏳`);
|
||||
const labelPend = padLeftSpComputed(this.plugin.totalQueued, `🛫`);
|
||||
const labelInBatchDelay = padLeftSpComputed(this.plugin.batched, `📬`);
|
||||
const labelProc = padLeftSpComputed(this.core.processing, `⏳`);
|
||||
const labelPend = padLeftSpComputed(this.core.totalQueued, `🛫`);
|
||||
const labelInBatchDelay = padLeftSpComputed(this.core.batched, `📬`);
|
||||
const waitingLabel = computed(() => {
|
||||
return `${labelProc()}${labelPend()}${labelInBatchDelay()}`;
|
||||
})
|
||||
@@ -144,7 +144,7 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
};
|
||||
})
|
||||
const statusBarLabels = reactive(() => {
|
||||
const scheduleMessage = this.plugin.isReloadingScheduled ? `WARNING! RESTARTING OBSIDIAN IS SCHEDULED!\n` : "";
|
||||
const scheduleMessage = this.core.$$isReloadingScheduled() ? `WARNING! RESTARTING OBSIDIAN IS SCHEDULED!\n` : "";
|
||||
const { message } = statusLineLabel();
|
||||
const status = scheduleMessage + this.statusLog.value;
|
||||
|
||||
@@ -181,7 +181,7 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
const thisFile = this.app.workspace.getActiveFile();
|
||||
if (!thisFile) return "";
|
||||
// Case Sensitivity
|
||||
if (this.core.shouldCheckCaseInsensitive) {
|
||||
if (this.core.$$shouldCheckCaseInsensitive()) {
|
||||
const f = this.core.storageAccess.getFiles().map(e => e.path).filter(e => e.toLowerCase() == thisFile.path.toLowerCase());
|
||||
if (f.length > 1) return "Not synchronised: There are multiple files with the same name";
|
||||
}
|
||||
@@ -274,7 +274,7 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
}
|
||||
$everyOnloadAfterLoadSettings(): Promise<boolean> {
|
||||
logStore.pipeTo(new QueueProcessor(logs => logs.forEach(e => this.core.$$addLog(e.message, e.level, e.key)), { suspended: false, batchSize: 20, concurrentLimit: 1, delay: 0 })).startPipeline();
|
||||
eventHub.onEvent(EVENT_FILE_RENAMED, (evt: CustomEvent<{ oldPath: string, newPath: string }>) => {
|
||||
eventHub.onEvent(EVENT_FILE_RENAMED, (data) => {
|
||||
void this.setFileStatus();
|
||||
});
|
||||
|
||||
@@ -290,7 +290,7 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
this.logHistory = this.statusDiv.createDiv({ cls: "livesync-status-loghistory" });
|
||||
eventHub.onEvent(EVENT_LAYOUT_READY, () => this.adjustStatusDivPosition());
|
||||
if (this.settings?.showStatusOnStatusbar) {
|
||||
this.statusBar = this.plugin.addStatusBarItem();
|
||||
this.statusBar = this.core.addStatusBarItem();
|
||||
this.statusBar.addClass("syncstatusbar");
|
||||
}
|
||||
this.adjustStatusDivPosition();
|
||||
@@ -318,7 +318,7 @@ export class ModuleLog extends AbstractObsidianModule implements IObsidianModule
|
||||
if (this.settings && !this.settings.showVerboseLog && level == LOG_LEVEL_VERBOSE) {
|
||||
return;
|
||||
}
|
||||
const vaultName = this.plugin.$$getVaultName();
|
||||
const vaultName = this.core.$$getVaultName();
|
||||
const now = new Date();
|
||||
const timestamp = now.toLocaleString();
|
||||
const messageContent = typeof message == "string" ? message : message instanceof Error ? `${message.name}:${message.message}` : JSON.stringify(message, null, 2);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { type TFile } from "obsidian";
|
||||
import { eventHub, EVENT_REQUEST_SHOW_HISTORY } from "../../common/events.ts";
|
||||
import { eventHub } from "../../common/events.ts";
|
||||
import { EVENT_REQUEST_SHOW_HISTORY } from "../../common/obsidianEvents.ts";
|
||||
import type { FilePathWithPrefix, LoadedEntry, DocumentID } from "../../lib/src/common/types.ts";
|
||||
import { AbstractObsidianModule, type IObsidianModule } from "../AbstractObsidianModule.ts";
|
||||
import { DocumentHistoryModal } from "./DocumentHistory/DocumentHistoryModal.ts";
|
||||
@@ -29,7 +30,7 @@ export class ModuleObsidianDocumentHistory extends AbstractObsidianModule implem
|
||||
fireAndForget(async () => await this.fileHistory());
|
||||
},
|
||||
});
|
||||
eventHub.on(EVENT_REQUEST_SHOW_HISTORY, ({ file, fileOnDB }: { file: TFile, fileOnDB: LoadedEntry }) => {
|
||||
eventHub.onEvent(EVENT_REQUEST_SHOW_HISTORY, ({ file, fileOnDB }: { file: TFile | FilePathWithPrefix, fileOnDB: LoadedEntry }) => {
|
||||
this.showHistory(file, fileOnDB._id);
|
||||
})
|
||||
return Promise.resolve(true);
|
||||
@@ -46,7 +47,7 @@ export class ModuleObsidianDocumentHistory extends AbstractObsidianModule implem
|
||||
}
|
||||
notes.sort((a, b) => b.mtime - a.mtime);
|
||||
const notesList = notes.map(e => e.dispPath);
|
||||
const target = await this.plugin.confirm.askSelectString("File to view History", notesList);
|
||||
const target = await this.core.confirm.askSelectString("File to view History", notesList);
|
||||
if (target) {
|
||||
const targetId = notes.find(e => e.dispPath == target)!;
|
||||
this.showHistory(targetId.path, targetId.id);
|
||||
|
||||
@@ -12,7 +12,7 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
|
||||
const methods: Record<ConfigPassphraseStore, (() => Promise<string | false>)> = {
|
||||
"": () => Promise.resolve("*"),
|
||||
"LOCALSTORAGE": () => Promise.resolve(localStorage.getItem("ls-setting-passphrase") ?? false),
|
||||
"ASK_AT_LAUNCH": () => this.plugin.confirm.askString("Passphrase", "passphrase", "")
|
||||
"ASK_AT_LAUNCH": () => this.core.confirm.askString("Passphrase", "passphrase", "")
|
||||
}
|
||||
const method = settings.configPassphraseStore;
|
||||
const methodFunc = method in methods ? methods[method] : methods[""];
|
||||
@@ -20,8 +20,8 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
|
||||
}
|
||||
|
||||
$$saveDeviceAndVaultName(): void {
|
||||
const lsKey = "obsidian-live-sync-vaultanddevicename-" + this.plugin.$$getVaultName();
|
||||
localStorage.setItem(lsKey, this.plugin.deviceAndVaultName || "");
|
||||
const lsKey = "obsidian-live-sync-vaultanddevicename-" + this.core.$$getVaultName();
|
||||
localStorage.setItem(lsKey, this.core.$$getDeviceAndVaultName() || "");
|
||||
}
|
||||
|
||||
usedPassphrase = "";
|
||||
@@ -64,7 +64,7 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
|
||||
}
|
||||
|
||||
async $$saveSettingData() {
|
||||
this.plugin.$$saveDeviceAndVaultName();
|
||||
this.core.$$saveDeviceAndVaultName();
|
||||
const settings = { ...this.settings };
|
||||
settings.deviceAndVaultName = "";
|
||||
if (this.usedPassphrase == "" && !await this.getPassphrase(settings)) {
|
||||
@@ -182,11 +182,11 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
|
||||
// So, use history is always enabled.
|
||||
this.settings.useHistory = true;
|
||||
|
||||
const lsKey = "obsidian-live-sync-vaultanddevicename-" + this.plugin.$$getVaultName();
|
||||
const lsKey = "obsidian-live-sync-vaultanddevicename-" + this.core.$$getVaultName();
|
||||
if (this.settings.deviceAndVaultName != "") {
|
||||
if (!localStorage.getItem(lsKey)) {
|
||||
this.core.deviceAndVaultName = this.settings.deviceAndVaultName;
|
||||
localStorage.setItem(lsKey, this.core.deviceAndVaultName);
|
||||
this.core.$$setDeviceAndVaultName(this.settings.deviceAndVaultName);
|
||||
this.$$saveDeviceAndVaultName();
|
||||
this.settings.deviceAndVaultName = "";
|
||||
}
|
||||
}
|
||||
@@ -194,8 +194,8 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
|
||||
this._log("Configuration verification founds problems with your configuration. This has been fixed automatically. But you may already have data that cannot be synchronised. If this is the case, please rebuild everything.", LOG_LEVEL_NOTICE)
|
||||
this.settings.customChunkSize = 0;
|
||||
}
|
||||
this.core.deviceAndVaultName = localStorage.getItem(lsKey) || "";
|
||||
if (this.core.deviceAndVaultName == "") {
|
||||
this.core.$$setDeviceAndVaultName(localStorage.getItem(lsKey) || "");
|
||||
if (this.core.$$getDeviceAndVaultName() == "") {
|
||||
if (this.settings.usePluginSync) {
|
||||
this._log("Device name is not set. Plug-in sync has been disabled.", LOG_LEVEL_NOTICE);
|
||||
this.settings.usePluginSync = false;
|
||||
|
||||
@@ -19,7 +19,7 @@ export class ModuleObsidianSettingsAsMarkdown extends AbstractObsidianModule imp
|
||||
return this.settings.settingSyncFile != "";
|
||||
}
|
||||
fireAndForget(async () => {
|
||||
await this.plugin.$$saveSettingData();
|
||||
await this.core.$$saveSettingData();
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -38,13 +38,12 @@ export class ModuleObsidianSettingsAsMarkdown extends AbstractObsidianModule imp
|
||||
}
|
||||
},
|
||||
})
|
||||
eventHub.on("event-file-changed", (info: {
|
||||
eventHub.onEvent("event-file-changed", (info: {
|
||||
file: FilePathWithPrefix, automated: boolean
|
||||
}) => {
|
||||
fireAndForget(() => this.checkAndApplySettingFromMarkdown(info.file, info.automated));
|
||||
});
|
||||
eventHub.onEvent(EVENT_SETTING_SAVED, (evt: CustomEvent<ObsidianLiveSyncSettings>) => {
|
||||
const settings = evt.detail;
|
||||
eventHub.onEvent(EVENT_SETTING_SAVED, (settings: ObsidianLiveSyncSettings) => {
|
||||
if (settings.settingSyncFile != "") {
|
||||
fireAndForget(() => this.saveSettingToMarkdown(settings.settingSyncFile));
|
||||
}
|
||||
@@ -123,7 +122,7 @@ export class ModuleObsidianSettingsAsMarkdown extends AbstractObsidianModule imp
|
||||
return
|
||||
}
|
||||
const addMsg = this.settings.settingSyncFile != filename ? " (This is not-active file)" : "";
|
||||
this.plugin.confirm.askInPopup("apply-setting-from-md", `Setting markdown ${filename}${addMsg} has been detected. Apply this from {HERE}.`, (anchor) => {
|
||||
this.core.confirm.askInPopup("apply-setting-from-md", `Setting markdown ${filename}${addMsg} has been detected. Apply this from {HERE}.`, (anchor) => {
|
||||
anchor.text = "HERE";
|
||||
anchor.addEventListener("click", () => {
|
||||
fireAndForget(async () => {
|
||||
@@ -132,26 +131,26 @@ export class ModuleObsidianSettingsAsMarkdown extends AbstractObsidianModule imp
|
||||
const APPLY_AND_REBUILD = "Apply settings and restart obsidian with red_flag_rebuild.md";
|
||||
const APPLY_AND_FETCH = "Apply settings and restart obsidian with red_flag_fetch.md";
|
||||
const CANCEL = "Cancel";
|
||||
const result = await this.plugin.confirm.askSelectStringDialogue("Ready for apply the setting.", [
|
||||
const result = await this.core.confirm.askSelectStringDialogue("Ready for apply the setting.", [
|
||||
APPLY_AND_RESTART,
|
||||
APPLY_ONLY,
|
||||
APPLY_AND_FETCH,
|
||||
APPLY_AND_REBUILD,
|
||||
CANCEL], { defaultAction: APPLY_AND_RESTART });
|
||||
if (result == APPLY_ONLY || result == APPLY_AND_RESTART || result == APPLY_AND_REBUILD || result == APPLY_AND_FETCH) {
|
||||
this.plugin.settings = settingToApply;
|
||||
await this.plugin.$$saveSettingData();
|
||||
this.core.settings = settingToApply;
|
||||
await this.core.$$saveSettingData();
|
||||
if (result == APPLY_ONLY) {
|
||||
this._log("Loaded settings have been applied!", LOG_LEVEL_NOTICE);
|
||||
return;
|
||||
}
|
||||
if (result == APPLY_AND_REBUILD) {
|
||||
await this.plugin.rebuilder.scheduleRebuild();
|
||||
await this.core.rebuilder.scheduleRebuild();
|
||||
}
|
||||
if (result == APPLY_AND_FETCH) {
|
||||
await this.plugin.rebuilder.scheduleFetch();
|
||||
await this.core.rebuilder.scheduleFetch();
|
||||
}
|
||||
this.plugin.$$performRestart();
|
||||
this.core.$$performRestart();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,11 +20,12 @@ import { Semaphore } from "octagonal-wheels/concurrency/semaphore";
|
||||
import { LiveSyncSetting as Setting } from "./LiveSyncSetting.ts";
|
||||
import { fireAndForget, yieldNextAnimationFrame } from "octagonal-wheels/promises";
|
||||
import { confirmWithMessage } from "../../coreObsidian/UILib/dialogs.ts";
|
||||
import { EVENT_REQUEST_COPY_SETUP_URI, EVENT_REQUEST_OPEN_PLUGIN_SYNC_DIALOG, EVENT_REQUEST_OPEN_SETUP_URI, EVENT_REQUEST_RELOAD_SETTING_TAB, EVENT_REQUEST_SHOW_HISTORY, eventHub } from "../../../common/events.ts";
|
||||
import { EVENT_REQUEST_COPY_SETUP_URI, EVENT_REQUEST_OPEN_PLUGIN_SYNC_DIALOG, EVENT_REQUEST_OPEN_SETUP_URI, EVENT_REQUEST_RELOAD_SETTING_TAB, eventHub } from "../../../common/events.ts";
|
||||
import { skipIfDuplicated } from "octagonal-wheels/concurrency/lock";
|
||||
import { JournalSyncMinio } from "../../../lib/src/replication/journal/objectstore/JournalSyncMinio.ts";
|
||||
import { ICHeader, ICXHeader, PSCHeader } from "../../../common/types.ts";
|
||||
import { HiddenFileSync } from "../../../features/HiddenFileSync/CmdHiddenFileSync.ts";
|
||||
import { EVENT_REQUEST_SHOW_HISTORY } from "../../../common/obsidianEvents.ts";
|
||||
|
||||
export type OnUpdateResult = {
|
||||
visibility?: boolean,
|
||||
@@ -162,7 +163,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
return await Promise.resolve();
|
||||
}
|
||||
if (key == "deviceAndVaultName") {
|
||||
this.plugin.deviceAndVaultName = this.editingSettings?.[key] ?? "";
|
||||
this.plugin.$$setDeviceAndVaultName(this.editingSettings?.[key] ?? "");
|
||||
this.plugin.$$saveDeviceAndVaultName();
|
||||
return await Promise.resolve();
|
||||
}
|
||||
@@ -230,7 +231,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
const ret = { ...OnDialogSettingsDefault };
|
||||
ret.configPassphrase = localStorage.getItem("ls-setting-passphrase") || "";
|
||||
ret.preset = ""
|
||||
ret.deviceAndVaultName = this.plugin.deviceAndVaultName;
|
||||
ret.deviceAndVaultName = this.plugin.$$getDeviceAndVaultName();
|
||||
return ret;
|
||||
}
|
||||
computeAllLocalSettings(): Partial<OnDialogSettings> {
|
||||
@@ -304,7 +305,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
Setting.env = this;
|
||||
eventHub.on(EVENT_REQUEST_RELOAD_SETTING_TAB, () => {
|
||||
eventHub.onEvent(EVENT_REQUEST_RELOAD_SETTING_TAB, () => {
|
||||
this.requestReload();
|
||||
})
|
||||
}
|
||||
@@ -710,7 +711,7 @@ Store only the settings. **Caution: This may lead to data corruption**; database
|
||||
const replicator = this.plugin.$anyNewReplicator(settingForCheck);
|
||||
if (!(replicator instanceof LiveSyncCouchDBReplicator)) return true;
|
||||
|
||||
const db = await replicator.connectRemoteCouchDBWithSetting(settingForCheck, this.plugin.isMobile, true);
|
||||
const db = await replicator.connectRemoteCouchDBWithSetting(settingForCheck, this.plugin.$$isMobile(), true);
|
||||
if (typeof db === "string") {
|
||||
Logger(`ERROR: Failed to check passphrase with the remote server: \n${db}.`, LOG_LEVEL_NOTICE);
|
||||
return false;
|
||||
@@ -1187,7 +1188,7 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
|
||||
|
||||
void addPanel(paneEl, "CouchDB", undefined, onlyOnCouchDB).then(paneEl => {
|
||||
if (this.plugin.isMobile) {
|
||||
if (this.plugin.$$isMobile()) {
|
||||
this.createEl(paneEl, "div", {
|
||||
text: `Configured as using non-HTTPS. We cannot connect to the remote. Please set up the credentials and use HTTPS for the remote URI.`,
|
||||
}, undefined, visibleOnly(() => !this.editingSettings.couchDB_URI.startsWith("https://")))
|
||||
@@ -1280,6 +1281,23 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
}).setClass("wizardHidden");
|
||||
|
||||
});
|
||||
|
||||
void addPanel(paneEl, "Fetch settings").then((paneEl) => {
|
||||
new Setting(paneEl)
|
||||
.setName("Fetch tweaks from the remote")
|
||||
.setDesc("Fetch other necessary settings from already configured remote.")
|
||||
.addButton((button) => button
|
||||
.setButtonText("Fetch")
|
||||
.setDisabled(false)
|
||||
.onClick(async () => {
|
||||
const trialSetting = { ...this.initialSettings, ...this.editingSettings, };
|
||||
const newTweaks = await this.plugin.$$checkAndAskUseRemoteConfiguration(trialSetting);
|
||||
if (newTweaks.result !== false) {
|
||||
this.editingSettings = { ...this.editingSettings, ...newTweaks.result };
|
||||
this.requestUpdate();
|
||||
}
|
||||
}));
|
||||
});
|
||||
new Setting(paneEl)
|
||||
.setClass("wizardOnly")
|
||||
.addButton((button) => button
|
||||
@@ -1313,6 +1331,16 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
} else {
|
||||
this.editingSettings = { ...this.editingSettings, ...PREFERRED_SETTING_SELF_HOSTED };
|
||||
}
|
||||
if (await this.plugin.confirm.askYesNoDialog("Do you want to fetch the tweaks from the remote?", { defaultOption: "Yes", title: "Fetch tweaks" }) == "yes") {
|
||||
const trialSetting = { ...this.initialSettings, ...this.editingSettings, };
|
||||
const newTweaks = await this.plugin.$$checkAndAskUseRemoteConfiguration(trialSetting);
|
||||
if (newTweaks.result !== false) {
|
||||
this.editingSettings = { ...this.editingSettings, ...newTweaks.result };
|
||||
this.requestUpdate();
|
||||
} else {
|
||||
// Messages should be already shown.
|
||||
}
|
||||
}
|
||||
changeDisplay("30")
|
||||
}));
|
||||
});
|
||||
@@ -1360,7 +1388,8 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
}).addButton(button => {
|
||||
button.setButtonText("Apply");
|
||||
button.onClick(async () => {
|
||||
await this.saveSettings(["preset"]);
|
||||
// await this.saveSettings(["preset"]);
|
||||
await this.saveAllDirtySettings();
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1416,7 +1445,7 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
if (!this.editingSettings.isConfigured) {
|
||||
this.editingSettings.isConfigured = true;
|
||||
await this.saveAllDirtySettings();
|
||||
await this.plugin.realizeSettingSyncMode();
|
||||
await this.plugin.$$realizeSettingSyncMode();
|
||||
await rebuildDB("localOnly");
|
||||
// this.resetEditingSettings();
|
||||
if (await this.plugin.confirm.askYesNoDialog(
|
||||
@@ -1430,13 +1459,13 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
await confirmRebuild();
|
||||
} else {
|
||||
await this.saveAllDirtySettings();
|
||||
await this.plugin.realizeSettingSyncMode();
|
||||
await this.plugin.$$realizeSettingSyncMode();
|
||||
this.plugin.$$askReload();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await this.saveAllDirtySettings();
|
||||
await this.plugin.realizeSettingSyncMode();
|
||||
await this.plugin.$$realizeSettingSyncMode();
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1471,7 +1500,7 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
}
|
||||
await this.saveSettings(["liveSync", "periodicReplication"]);
|
||||
|
||||
await this.plugin.realizeSettingSyncMode();
|
||||
await this.plugin.$$realizeSettingSyncMode();
|
||||
})
|
||||
|
||||
|
||||
@@ -1546,6 +1575,8 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
});
|
||||
|
||||
void addPanel(paneEl, "Sync settings via markdown", undefined, undefined, LEVEL_ADVANCED).then((paneEl) => {
|
||||
paneEl.addClass("wizardHidden");
|
||||
|
||||
new Setting(paneEl)
|
||||
.autoWireText("settingSyncFile", { holdValue: true })
|
||||
.addApplyButton(["settingSyncFile"])
|
||||
@@ -1569,7 +1600,6 @@ However, your report is needed to stabilise this. I appreciate you for your grea
|
||||
const hiddenFileSyncSettingEl = hiddenFileSyncSetting.settingEl
|
||||
const hiddenFileSyncSettingDiv = hiddenFileSyncSettingEl.createDiv("");
|
||||
hiddenFileSyncSettingDiv.innerText = this.editingSettings.syncInternalFiles ? LABEL_ENABLED : LABEL_DISABLED;
|
||||
|
||||
if (this.editingSettings.syncInternalFiles) {
|
||||
new Setting(paneEl)
|
||||
.setName("Disable Hidden files sync")
|
||||
@@ -1979,7 +2009,7 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
.split(",").filter(e => e).map(e => new RegExp(e, "i"));
|
||||
this.plugin.localDatabase.hashCaches.clear();
|
||||
Logger("Start verifying all files", LOG_LEVEL_NOTICE, "verify");
|
||||
const files = await this.plugin.storageAccess.getFilesIncludeHidden("/", undefined, ignorePatterns)
|
||||
const files = this.plugin.settings.syncInternalFiles ? (await this.plugin.storageAccess.getFilesIncludeHidden("/", undefined, ignorePatterns)) : (await this.plugin.storageAccess.getFileNames());
|
||||
const documents = [] as FilePath[];
|
||||
|
||||
const adn = this.plugin.localDatabase.findAllDocs()
|
||||
@@ -1987,6 +2017,7 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
const path = getPath(i);
|
||||
if (path.startsWith(ICXHeader)) continue;
|
||||
if (path.startsWith(PSCHeader)) continue;
|
||||
if (!this.plugin.settings.syncInternalFiles && path.startsWith(ICHeader)) continue;
|
||||
documents.push(stripAllPrefixes(path));
|
||||
}
|
||||
const allPaths = [
|
||||
@@ -2648,9 +2679,9 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
|
||||
async dryRunGC() {
|
||||
await skipIfDuplicated("cleanup", async () => {
|
||||
const replicator = this.plugin.getReplicator();
|
||||
const replicator = this.plugin.$$getReplicator();
|
||||
if (!(replicator instanceof LiveSyncCouchDBReplicator)) return;
|
||||
const remoteDBConn = await replicator.connectRemoteCouchDBWithSetting(this.plugin.settings, this.plugin.isMobile)
|
||||
const remoteDBConn = await replicator.connectRemoteCouchDBWithSetting(this.plugin.settings, this.plugin.$$isMobile())
|
||||
if (typeof (remoteDBConn) == "string") {
|
||||
Logger(remoteDBConn);
|
||||
return;
|
||||
@@ -2664,10 +2695,10 @@ ${stringifyYaml(pluginConfig)}`;
|
||||
async dbGC() {
|
||||
// Lock the remote completely once.
|
||||
await skipIfDuplicated("cleanup", async () => {
|
||||
const replicator = this.plugin.getReplicator();
|
||||
const replicator = this.plugin.$$getReplicator();
|
||||
if (!(replicator instanceof LiveSyncCouchDBReplicator)) return;
|
||||
await this.plugin.getReplicator().markRemoteLocked(this.plugin.settings, true, true);
|
||||
const remoteDBConnection = await replicator.connectRemoteCouchDBWithSetting(this.plugin.settings, this.plugin.isMobile)
|
||||
await this.plugin.$$getReplicator().markRemoteLocked(this.plugin.settings, true, true);
|
||||
const remoteDBConnection = await replicator.connectRemoteCouchDBWithSetting(this.plugin.settings, this.plugin.$$isMobile())
|
||||
if (typeof (remoteDBConnection) == "string") {
|
||||
Logger(remoteDBConnection);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user