Skip to content

Commit b959292

Browse files
committed
#22 - bugfix of the status indicator in ribbon icon sometimes not updated
- plus version bump for release
1 parent 641690e commit b959292

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "custom-sort",
33
"name": "Custom File Explorer sorting",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"minAppVersion": "0.15.0",
66
"description": "Allows for manual and automatic, config-driven reordering and sorting of files and folders in File Explorer",
77
"author": "SebastianMC",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-custom-sort",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class CustomSortPlugin extends Plugin {
5252
settings: CustomSortPluginSettings
5353
statusBarItemEl: HTMLElement
5454
ribbonIconEl: HTMLElement
55+
ribbonIconStateInaccurate: boolean
5556

5657
sortSpecCache?: SortSpecsCollection | null
5758
initialAutoOrManualSortingTriggered: boolean
@@ -152,6 +153,10 @@ export default class CustomSortPlugin extends Plugin {
152153
} else {
153154
if (iconToSet === ICON_SORT_ENABLED_ACTIVE) {
154155
iconToSet = ICON_SORT_ENABLED_NOT_APPLIED
156+
157+
if (updateRibbonBtnIcon) {
158+
this.ribbonIconStateInaccurate = true
159+
}
155160
}
156161
}
157162

@@ -163,7 +168,7 @@ export default class CustomSortPlugin extends Plugin {
163168
}
164169

165170
async onload() {
166-
console.log("loading custom-sort");
171+
console.log(`loading custom-sort v${this.manifest.version}`);
167172

168173
await this.loadSettings();
169174

@@ -183,6 +188,10 @@ export default class CustomSortPlugin extends Plugin {
183188
this.switchPluginStateTo(this.settings.suspended)
184189
});
185190

191+
if (!this.settings.suspended) {
192+
this.ribbonIconStateInaccurate = true
193+
}
194+
186195
this.addSettingTab(new CustomSortSettingTab(this.app, this));
187196

188197
this.registerEventHandlers()
@@ -193,6 +202,7 @@ export default class CustomSortPlugin extends Plugin {
193202
}
194203

195204
registerEventHandlers() {
205+
const plugin: CustomSortPlugin = this
196206
this.registerEvent(
197207
// Keep in mind: this event is triggered once after app starts and then after each modification of _any_ metadata
198208
this.app.metadataCache.on("resolved", () => {
@@ -208,6 +218,7 @@ export default class CustomSortPlugin extends Plugin {
208218
fileExplorerView.requestSort()
209219
} else {
210220
setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_NOT_APPLIED)
221+
plugin.ribbonIconStateInaccurate = true
211222
}
212223
this.updateStatusBar()
213224
} else {
@@ -261,6 +272,11 @@ export default class CustomSortPlugin extends Plugin {
261272
return old.call(this, ...args);
262273
}
263274

275+
if (plugin.ribbonIconStateInaccurate && plugin.ribbonIconEl) {
276+
plugin.ribbonIconStateInaccurate = false
277+
setIcon(plugin.ribbonIconEl, ICON_SORT_ENABLED_ACTIVE)
278+
}
279+
264280
// if custom sort is not specified, use the UI-selected
265281
const folder: TFolder = this.file
266282
let sortSpec: CustomSortSpec | null | undefined = plugin.sortSpecCache?.sortSpecByPath[folder.path]

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
"0.8.4": "0.15.0",
1515
"1.0.0": "0.15.0",
1616
"1.0.1": "0.15.0",
17-
"1.0.2": "0.15.0"
17+
"1.0.2": "0.15.0",
18+
"1.0.3": "0.15.0"
1819
}

0 commit comments

Comments
 (0)