@@ -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 ]
0 commit comments