#188 - Group of changes addressing compatibility issued with Obsidian 1.7.2 and newer
This commit is contained in:
parent
92c0e0c431
commit
ef5926c24f
25
src/main.ts
25
src/main.ts
|
@ -1,4 +1,6 @@
|
||||||
import {
|
import {
|
||||||
|
App,
|
||||||
|
CommunityPlugin,
|
||||||
FileExplorerLeaf,
|
FileExplorerLeaf,
|
||||||
FileExplorerView,
|
FileExplorerView,
|
||||||
Menu,
|
Menu,
|
||||||
|
@ -43,7 +45,7 @@ import {
|
||||||
groupNameForPath
|
groupNameForPath
|
||||||
} from "./utils/BookmarksCorePluginSignature";
|
} from "./utils/BookmarksCorePluginSignature";
|
||||||
import {
|
import {
|
||||||
getIconFolderPlugin
|
getIconFolderPlugin, ObsidianIconFolder_PluginInstance, ObsidianIconFolderPlugin_getData_methodName
|
||||||
} from "./utils/ObsidianIconFolderPluginSignature";
|
} from "./utils/ObsidianIconFolderPluginSignature";
|
||||||
import {
|
import {
|
||||||
extractBasename,
|
extractBasename,
|
||||||
|
@ -64,6 +66,8 @@ import {
|
||||||
} from "./settings";
|
} from "./settings";
|
||||||
import {CustomSortPluginAPI} from "./custom-sort-plugin";
|
import {CustomSortPluginAPI} from "./custom-sort-plugin";
|
||||||
|
|
||||||
|
const PLUGIN_ID = 'custom-sort' // same as in manifest.json
|
||||||
|
|
||||||
const SORTSPEC_FILE_NAME: string = 'sortspec.md'
|
const SORTSPEC_FILE_NAME: string = 'sortspec.md'
|
||||||
const SORTINGSPEC_YAML_KEY: string = 'sorting-spec'
|
const SORTINGSPEC_YAML_KEY: string = 'sorting-spec'
|
||||||
|
|
||||||
|
@ -266,13 +270,13 @@ export default class CustomSortPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
logWarningFileExplorerDeferred() {
|
logWarningFileExplorerDeferred() {
|
||||||
const msg = `custom-sort v${this.manifest.version}: failed to get active File Explorer view.\n`
|
const msg = `${PLUGIN_ID} v${this.manifest.version}: failed to get active File Explorer view.\n`
|
||||||
+ `Until the File Explorer is visible, the custom-sort plugin cannot apply the custom order.\n`
|
+ `Until the File Explorer is visible, the custom-sort plugin cannot apply the custom order.\n`
|
||||||
console.warn(msg)
|
console.warn(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
logWarningFileExplorerNotAvailable() {
|
logWarningFileExplorerNotAvailable() {
|
||||||
const msg = `custom-sort v${this.manifest.version}: failed to locate File Explorer. The 'Files' core plugin can be disabled.\n`
|
const msg = `${PLUGIN_ID} v${this.manifest.version}: failed to locate File Explorer. The 'Files' core plugin can be disabled.\n`
|
||||||
+ `Some community plugins can also disable it.\n`
|
+ `Some community plugins can also disable it.\n`
|
||||||
+ `See the example of MAKE.md plugin: https://github.com/Make-md/makemd/issues/25\n`
|
+ `See the example of MAKE.md plugin: https://github.com/Make-md/makemd/issues/25\n`
|
||||||
+ `You can find there instructions on how to re-enable the File Explorer in MAKE.md plugin`
|
+ `You can find there instructions on how to re-enable the File Explorer in MAKE.md plugin`
|
||||||
|
@ -323,7 +327,7 @@ export default class CustomSortPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
async onload() {
|
async onload() {
|
||||||
console.log(`loading custom-sort v${this.manifest.version}`);
|
console.log(`loading ${PLUGIN_ID} v${this.manifest.version}`);
|
||||||
|
|
||||||
await this.loadSettings();
|
await this.loadSettings();
|
||||||
|
|
||||||
|
@ -665,9 +669,18 @@ export default class CustomSortPlugin
|
||||||
await this.saveData(this.settings);
|
await this.saveData(this.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isThePluginStillInstalledAndEnabled(): boolean {
|
||||||
|
const thisPlugin: CommunityPlugin | undefined = this?.app?.plugins?.plugins?.[PLUGIN_ID]
|
||||||
|
if (thisPlugin && thisPlugin._loaded && this?.app?.plugins?.enabledPlugins?.has(PLUGIN_ID)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
initialDelayedApplicationOfCustomSorting() {
|
initialDelayedApplicationOfCustomSorting() {
|
||||||
if (!this) {
|
if (!this?.isThePluginStillInstalledAndEnabled()) {
|
||||||
return // sanity check - plugin removed from the system?
|
console.log(`${PLUGIN_ID} v${this.manifest.version} - delayed handler skipped, plugin no longer active.`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// should be applied? yes (based on settings)
|
// should be applied? yes (based on settings)
|
||||||
|
|
Loading…
Reference in New Issue