11import {
2+ App ,
3+ CommunityPlugin ,
24 FileExplorerLeaf ,
35 FileExplorerView ,
4- Menu ,
5- MenuItem ,
6+ Menu ,
7+ MenuItem ,
68 MetadataCache ,
79 Notice ,
810 Platform ,
@@ -43,7 +45,7 @@ import {
4345 groupNameForPath
4446} from "./utils/BookmarksCorePluginSignature" ;
4547import {
46- getIconFolderPlugin
48+ getIconFolderPlugin , ObsidianIconFolder_PluginInstance , ObsidianIconFolderPlugin_getData_methodName
4749} from "./utils/ObsidianIconFolderPluginSignature" ;
4850import {
4951 extractBasename ,
@@ -64,6 +66,8 @@ import {
6466} from "./settings" ;
6567import { CustomSortPluginAPI } from "./custom-sort-plugin" ;
6668
69+ const PLUGIN_ID = 'custom-sort' // same as in manifest.json
70+
6771const SORTSPEC_FILE_NAME : string = 'sortspec.md'
6872const SORTINGSPEC_YAML_KEY : string = 'sorting-spec'
6973
@@ -266,13 +270,13 @@ export default class CustomSortPlugin
266270 }
267271
268272 logWarningFileExplorerDeferred ( ) {
269- const msg = `custom-sort v${ this . manifest . version } : failed to get active File Explorer view.\n`
273+ const msg = `${ PLUGIN_ID } v${ this . manifest . version } : failed to get active File Explorer view.\n`
270274 + `Until the File Explorer is visible, the custom-sort plugin cannot apply the custom order.\n`
271275 console . warn ( msg )
272276 }
273277
274278 logWarningFileExplorerNotAvailable ( ) {
275- const msg = `custom-sort v${ this . manifest . version } : failed to locate File Explorer. The 'Files' core plugin can be disabled.\n`
279+ const msg = `${ PLUGIN_ID } v${ this . manifest . version } : failed to locate File Explorer. The 'Files' core plugin can be disabled.\n`
276280 + `Some community plugins can also disable it.\n`
277281 + `See the example of MAKE.md plugin: https://github.com/Make-md/makemd/issues/25\n`
278282 + `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
323327 }
324328
325329 async onload ( ) {
326- console . log ( `loading custom-sort v${ this . manifest . version } ` ) ;
330+ console . log ( `loading ${ PLUGIN_ID } v${ this . manifest . version } ` ) ;
327331
328332 await this . loadSettings ( ) ;
329333
@@ -665,9 +669,18 @@ export default class CustomSortPlugin
665669 await this . saveData ( this . settings ) ;
666670 }
667671
672+ isThePluginStillInstalledAndEnabled ( ) : boolean {
673+ const thisPlugin : CommunityPlugin | undefined = this ?. app ?. plugins ?. plugins ?. [ PLUGIN_ID ]
674+ if ( thisPlugin && thisPlugin . _loaded && this ?. app ?. plugins ?. enabledPlugins ?. has ( PLUGIN_ID ) ) {
675+ return true
676+ }
677+ return false
678+ }
679+
668680 initialDelayedApplicationOfCustomSorting ( ) {
669- if ( ! this ) {
670- return // sanity check - plugin removed from the system?
681+ if ( ! this ?. isThePluginStillInstalledAndEnabled ( ) ) {
682+ console . log ( `${ PLUGIN_ID } v${ this . manifest . version } - delayed handler skipped, plugin no longer active.` )
683+ return
671684 }
672685
673686 // should be applied? yes (based on settings)
0 commit comments