#22 - bugfix of the status indicator in ribbon icon sometimes not updated
- plus version bump for release
This commit is contained in:
parent
641690eac2
commit
b9592920b7
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "custom-sort",
|
||||
"name": "Custom File Explorer sorting",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Allows for manual and automatic, config-driven reordering and sorting of files and folders in File Explorer",
|
||||
"author": "SebastianMC",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-custom-sort",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
18
src/main.ts
18
src/main.ts
|
@ -52,6 +52,7 @@ export default class CustomSortPlugin extends Plugin {
|
|||
settings: CustomSortPluginSettings
|
||||
statusBarItemEl: HTMLElement
|
||||
ribbonIconEl: HTMLElement
|
||||
ribbonIconStateInaccurate: boolean
|
||||
|
||||
sortSpecCache?: SortSpecsCollection | null
|
||||
initialAutoOrManualSortingTriggered: boolean
|
||||
|
@ -152,6 +153,10 @@ export default class CustomSortPlugin extends Plugin {
|
|||
} else {
|
||||
if (iconToSet === ICON_SORT_ENABLED_ACTIVE) {
|
||||
iconToSet = ICON_SORT_ENABLED_NOT_APPLIED
|
||||
|
||||
if (updateRibbonBtnIcon) {
|
||||
this.ribbonIconStateInaccurate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +168,7 @@ export default class CustomSortPlugin extends Plugin {
|
|||
}
|
||||
|
||||
async onload() {
|
||||
console.log("loading custom-sort");
|
||||
console.log(`loading custom-sort v${this.manifest.version}`);
|
||||
|
||||
await this.loadSettings();
|
||||
|
||||
|
@ -183,6 +188,10 @@ export default class CustomSortPlugin extends Plugin {
|
|||
this.switchPluginStateTo(this.settings.suspended)
|
||||
});
|
||||
|
||||
if (!this.settings.suspended) {
|
||||
this.ribbonIconStateInaccurate = true
|
||||
}
|
||||
|
||||
this.addSettingTab(new CustomSortSettingTab(this.app, this));
|
||||
|
||||
this.registerEventHandlers()
|
||||
|
@ -193,6 +202,7 @@ export default class CustomSortPlugin extends Plugin {
|
|||
}
|
||||
|
||||
registerEventHandlers() {
|
||||
const plugin: CustomSortPlugin = this
|
||||
this.registerEvent(
|
||||
// Keep in mind: this event is triggered once after app starts and then after each modification of _any_ metadata
|
||||
this.app.metadataCache.on("resolved", () => {
|
||||
|
@ -208,6 +218,7 @@ export default class CustomSortPlugin extends Plugin {
|
|||
fileExplorerView.requestSort()
|
||||
} else {
|
||||
setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_NOT_APPLIED)
|
||||
plugin.ribbonIconStateInaccurate = true
|
||||
}
|
||||
this.updateStatusBar()
|
||||
} else {
|
||||
|
@ -261,6 +272,11 @@ export default class CustomSortPlugin extends Plugin {
|
|||
return old.call(this, ...args);
|
||||
}
|
||||
|
||||
if (plugin.ribbonIconStateInaccurate && plugin.ribbonIconEl) {
|
||||
plugin.ribbonIconStateInaccurate = false
|
||||
setIcon(plugin.ribbonIconEl, ICON_SORT_ENABLED_ACTIVE)
|
||||
}
|
||||
|
||||
// if custom sort is not specified, use the UI-selected
|
||||
const folder: TFolder = this.file
|
||||
let sortSpec: CustomSortSpec | null | undefined = plugin.sortSpecCache?.sortSpecByPath[folder.path]
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
"0.8.4": "0.15.0",
|
||||
"1.0.0": "0.15.0",
|
||||
"1.0.1": "0.15.0",
|
||||
"1.0.2": "0.15.0"
|
||||
"1.0.2": "0.15.0",
|
||||
"1.0.3": "0.15.0"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue