@@ -28,11 +28,13 @@ import {
2828interface CustomSortPluginSettings {
2929 additionalSortspecFile : string
3030 suspended : boolean
31+ statusBarEntryEnabled : boolean
3132}
3233
3334const DEFAULT_SETTINGS : CustomSortPluginSettings = {
3435 additionalSortspecFile : 'Inbox/Inbox.md' ,
35- suspended : true // if false by default, it would be hard to handle the auto-parse after plugin install
36+ suspended : true , // if false by default, it would be hard to handle the auto-parse after plugin install
37+ statusBarEntryEnabled : true
3638}
3739
3840const SORTSPEC_FILE_NAME : string = 'sortspec.md'
@@ -105,8 +107,10 @@ export default class CustomSortPlugin extends Plugin {
105107 await this . loadSettings ( ) ;
106108
107109 // This adds a status bar item to the bottom of the app. Does not work on mobile apps.
108- this . statusBarItemEl = this . addStatusBarItem ( ) ;
109- this . updateStatusBar ( )
110+ if ( this . settings . statusBarEntryEnabled ) {
111+ this . statusBarItemEl = this . addStatusBarItem ( ) ;
112+ this . updateStatusBar ( )
113+ }
110114
111115 addIcons ( ) ;
112116
@@ -284,5 +288,29 @@ class CustomSortSettingTab extends PluginSettingTab {
284288 this . plugin . settings . additionalSortspecFile = value ;
285289 await this . plugin . saveSettings ( ) ;
286290 } ) ) ;
291+
292+ new Setting ( containerEl )
293+ . setName ( 'Enable the status bar entry' )
294+ . setDesc ( 'The status bar entry shows the label `Custom sort:ON` or `Custom sort:OFF`, representing the current state of the plugin.' )
295+ . addToggle ( toggle => toggle
296+ . setValue ( this . plugin . settings . statusBarEntryEnabled )
297+ . onChange ( async ( value ) => {
298+ this . plugin . settings . statusBarEntryEnabled = value ;
299+ if ( value ) {
300+ // Enabling
301+ if ( this . plugin . statusBarItemEl ) {
302+ // for sanity
303+ this . plugin . statusBarItemEl . detach ( )
304+ }
305+ this . plugin . statusBarItemEl = this . plugin . addStatusBarItem ( ) ;
306+ this . plugin . updateStatusBar ( )
307+
308+ } else { // disabling
309+ if ( this . plugin . statusBarItemEl ) {
310+ this . plugin . statusBarItemEl . detach ( )
311+ }
312+ }
313+ await this . plugin . saveSettings ( ) ;
314+ } ) ) ;
287315 }
288316}
0 commit comments