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