mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-05-21 23:01:32 +00:00
0.24.0.dev-rc3
This commit is contained in:
@@ -343,7 +343,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
get useSyncPluginEtc() {
|
||||
return this.plugin.settings.usePluginEtc;
|
||||
}
|
||||
$isThisModuleEnabled() {
|
||||
_isThisModuleEnabled() {
|
||||
return this.plugin.settings.usePluginSync;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
|
||||
pluginList: IPluginDataExDisplay[] = [];
|
||||
showPluginSyncModal() {
|
||||
if (!this.$isThisModuleEnabled()) {
|
||||
if (!this._isThisModuleEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (this.pluginDialog) {
|
||||
@@ -417,7 +417,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
return this.getFileCategory(filePath) != "";
|
||||
}
|
||||
async $everyOnDatabaseInitialized(showNotice: boolean) {
|
||||
if (!this.$isThisModuleEnabled()) return true;
|
||||
if (!this._isThisModuleEnabled()) return true;
|
||||
try {
|
||||
Logger("Scanning customizations...");
|
||||
await this.scanAllConfigFiles(showNotice);
|
||||
@@ -429,7 +429,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
return true;
|
||||
}
|
||||
async $everyBeforeReplicate(showNotice: boolean) {
|
||||
if (!this.$isThisModuleEnabled()) return true;
|
||||
if (!this._isThisModuleEnabled()) return true;
|
||||
if (this.settings.autoSweepPlugins) {
|
||||
await this.scanAllConfigFiles(showNotice);
|
||||
return true;
|
||||
@@ -437,8 +437,8 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
return true;
|
||||
}
|
||||
async $everyOnResumeProcess(): Promise<boolean> {
|
||||
if (!this.$isThisModuleEnabled()) return true;
|
||||
if (this.$isMainSuspended()) {
|
||||
if (!this._isThisModuleEnabled()) return true;
|
||||
if (this._isMainSuspended()) {
|
||||
return true;
|
||||
}
|
||||
if (this.settings.autoSweepPlugins) {
|
||||
@@ -449,7 +449,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
}
|
||||
$everyAfterResumeProcess(): Promise<boolean> {
|
||||
const q = activeDocument.querySelector(`.livesync-ribbon-showcustom`);
|
||||
q?.toggleClass("sls-hidden", !this.$isThisModuleEnabled());
|
||||
q?.toggleClass("sls-hidden", !this._isThisModuleEnabled());
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
async reloadPluginList(showMessage: boolean) {
|
||||
@@ -754,7 +754,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
}
|
||||
|
||||
async updatePluginList(showMessage: boolean, updatedDocumentPath?: FilePathWithPrefix): Promise<void> {
|
||||
if (!this.$isThisModuleEnabled()) {
|
||||
if (!this._isThisModuleEnabled()) {
|
||||
this.pluginScanProcessor.clearQueue();
|
||||
this.pluginList = [];
|
||||
pluginList.set(this.pluginList)
|
||||
@@ -1019,10 +1019,10 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
}
|
||||
async $anyModuleParsedReplicationResultItem(docs: PouchDB.Core.ExistingDocument<EntryDoc>) {
|
||||
if (!docs._id.startsWith(ICXHeader)) return undefined;
|
||||
if (this.$isThisModuleEnabled()) {
|
||||
if (this._isThisModuleEnabled()) {
|
||||
await this.updatePluginList(false, (docs as AnyEntry).path ? (docs as AnyEntry).path : this.getPath((docs as AnyEntry)));
|
||||
}
|
||||
if (this.$isThisModuleEnabled() && this.plugin.settings.notifyPluginOrSettingUpdated) {
|
||||
if (this._isThisModuleEnabled() && this.plugin.settings.notifyPluginOrSettingUpdated) {
|
||||
if (!this.pluginDialog || (this.pluginDialog && !this.pluginDialog.isOpened())) {
|
||||
const fragment = createFragment((doc) => {
|
||||
doc.createEl("span", undefined, (a) => {
|
||||
@@ -1063,9 +1063,9 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
}
|
||||
async $everyRealizeSettingSyncMode(): Promise<boolean> {
|
||||
this.periodicPluginSweepProcessor?.disable();
|
||||
if (!this.$isMainReady) return true;
|
||||
if (!this.$isMainSuspended()) return true;
|
||||
if (!this.$isThisModuleEnabled()) return true;
|
||||
if (!this._isMainReady) return true;
|
||||
if (!this._isMainSuspended()) return true;
|
||||
if (!this._isThisModuleEnabled()) return true;
|
||||
if (this.settings.autoSweepPlugins) {
|
||||
await this.scanAllConfigFiles(false);
|
||||
}
|
||||
@@ -1323,9 +1323,9 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule {
|
||||
}
|
||||
|
||||
async watchVaultRawEventsAsync(path: FilePath) {
|
||||
// if (!this.$isMainReady) return true;
|
||||
// if (!this.$isMainSuspended()) return true;
|
||||
if (!this.$isThisModuleEnabled()) return true;
|
||||
if (!this._isMainReady) return true;
|
||||
if (!this._isMainSuspended()) return true;
|
||||
if (!this._isThisModuleEnabled()) return true;
|
||||
if (!this.isTargetPath(path)) return false;
|
||||
const stat = await this.plugin.storageAccess.statHidden(path);
|
||||
// Make sure that target is a file.
|
||||
|
||||
@@ -14,11 +14,11 @@ import type { IObsidianModule } from "../../modules/AbstractObsidianModule.ts";
|
||||
|
||||
export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule {
|
||||
|
||||
$isThisModuleEnabled() {
|
||||
_isThisModuleEnabled() {
|
||||
return this.plugin.settings.syncInternalFiles;
|
||||
}
|
||||
|
||||
periodicInternalFileScanProcessor: PeriodicProcessor = new PeriodicProcessor(this.plugin, async () => this.$isThisModuleEnabled() && this.$isDatabaseReady() && await this.syncInternalFilesAndDatabase("push", false));
|
||||
periodicInternalFileScanProcessor: PeriodicProcessor = new PeriodicProcessor(this.plugin, async () => this._isThisModuleEnabled() && this._isDatabaseReady() && await this.syncInternalFilesAndDatabase("push", false));
|
||||
|
||||
get kvDB() {
|
||||
return this.plugin.kvDB;
|
||||
@@ -39,7 +39,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
});
|
||||
}
|
||||
async $everyOnDatabaseInitialized(showNotice: boolean) {
|
||||
if (this.$isThisModuleEnabled()) {
|
||||
if (this._isThisModuleEnabled()) {
|
||||
try {
|
||||
Logger("Synchronizing hidden files...");
|
||||
await this.syncInternalFilesAndDatabase("push", showNotice);
|
||||
@@ -52,7 +52,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
return true;
|
||||
}
|
||||
async $everyBeforeReplicate(showNotice: boolean) {
|
||||
if (this.$isThisModuleEnabled() && this.$isDatabaseReady() && this.settings.syncInternalFilesBeforeReplication && !this.settings.watchInternalFileChanges) {
|
||||
if (this._isThisModuleEnabled() && this._isDatabaseReady() && this.settings.syncInternalFilesBeforeReplication && !this.settings.watchInternalFileChanges) {
|
||||
await this.syncInternalFilesAndDatabase("push", showNotice);
|
||||
}
|
||||
return true;
|
||||
@@ -61,22 +61,22 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
|
||||
async $everyOnResumeProcess(): Promise<boolean> {
|
||||
this.periodicInternalFileScanProcessor?.disable();
|
||||
if (this.$isMainSuspended())
|
||||
if (this._isMainSuspended())
|
||||
return true;
|
||||
if (this.$isThisModuleEnabled()) {
|
||||
if (this._isThisModuleEnabled()) {
|
||||
await this.syncInternalFilesAndDatabase("safe", false);
|
||||
}
|
||||
this.periodicInternalFileScanProcessor.enable(this.$isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0);
|
||||
this.periodicInternalFileScanProcessor.enable(this._isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0);
|
||||
return true
|
||||
}
|
||||
|
||||
$everyRealizeSettingSyncMode(): Promise<boolean> {
|
||||
this.periodicInternalFileScanProcessor?.disable();
|
||||
if (this.$isMainSuspended())
|
||||
if (this._isMainSuspended())
|
||||
return Promise.resolve(true);
|
||||
if (!this.plugin.isReady)
|
||||
return Promise.resolve(true);
|
||||
this.periodicInternalFileScanProcessor.enable(this.$isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0);
|
||||
this.periodicInternalFileScanProcessor.enable(this._isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
return await this.watchVaultRawEventsAsync(path);
|
||||
}
|
||||
async watchVaultRawEventsAsync(path: FilePath): Promise<boolean | undefined> {
|
||||
if (!this.$isThisModuleEnabled()) return false;
|
||||
if (!this._isThisModuleEnabled()) return false;
|
||||
if (!isInternalMetadata(path)) return false;
|
||||
|
||||
// Exclude files handled by customization sync
|
||||
@@ -274,7 +274,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule
|
||||
}
|
||||
|
||||
async $anyProcessOptionalSyncFiles(doc: LoadedEntry): Promise<boolean | undefined> {
|
||||
if (isInternalMetadata(doc._id) && this.$isThisModuleEnabled()) {
|
||||
if (isInternalMetadata(doc._id) && this._isThisModuleEnabled()) {
|
||||
//system file
|
||||
const filename = getPath(doc);
|
||||
if (await this.plugin.$$isTargetFile(filename)) {
|
||||
|
||||
@@ -31,13 +31,13 @@ export abstract class LiveSyncCommands {
|
||||
abstract onunload(): void;
|
||||
abstract onload(): void | Promise<void>;
|
||||
|
||||
$isMainReady() {
|
||||
return this.plugin.$isMainReady();
|
||||
_isMainReady() {
|
||||
return this.plugin._isMainReady();
|
||||
}
|
||||
$isMainSuspended() {
|
||||
return this.plugin.$isMainSuspended();
|
||||
_isMainSuspended() {
|
||||
return this.plugin._isMainSuspended();
|
||||
}
|
||||
$isDatabaseReady() {
|
||||
return this.plugin.$isDatabaseReady();
|
||||
_isDatabaseReady() {
|
||||
return this.plugin._isDatabaseReady();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user