Merge remote-tracking branch 'origin/master' into 13-feature-support-modified-date-sort-for-folders

This commit is contained in:
SebastianMC 2022-09-26 15:18:03 +02:00
commit 4e64925b2d
4 changed files with 31 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{
"id": "custom-sort",
"name": "Custom File Explorer sorting",
"version": "0.7.1",
"version": "0.7.2",
"minAppVersion": "0.15.0",
"description": "Allows for manual and automatic, config-driven reordering and sorting of files and folders in File Explorer",
"author": "SebastianMC <SebastianMC.github@gmail.com>",

View File

@ -1,6 +1,6 @@
{
"name": "obsidian-custom-sort",
"version": "0.7.1",
"version": "0.7.2",
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {

View File

@ -29,12 +29,14 @@ interface CustomSortPluginSettings {
additionalSortspecFile: string
suspended: boolean
statusBarEntryEnabled: boolean
notificationsEnabled: boolean
}
const DEFAULT_SETTINGS: CustomSortPluginSettings = {
additionalSortspecFile: 'Inbox/Inbox.md',
suspended: true, // if false by default, it would be hard to handle the auto-parse after plugin install
statusBarEntryEnabled: true
statusBarEntryEnabled: true,
notificationsEnabled: true
}
const SORTSPEC_FILE_NAME: string = 'sortspec.md'
@ -53,6 +55,12 @@ export default class CustomSortPlugin extends Plugin {
sortSpecCache?: SortSpecsCollection | null
initialAutoOrManualSortingTriggered: boolean
showNotice(message: string, timeout?: number) {
if (this.settings.notificationsEnabled) {
new Notice(message, timeout)
}
}
readAndParseSortingSpec() {
const mCache: MetadataCache = this.app.metadataCache
let failed: boolean = false
@ -91,14 +99,14 @@ export default class CustomSortPlugin extends Plugin {
})
if (this.sortSpecCache) {
new Notice(`Parsing custom sorting specification SUCCEEDED!`)
this.showNotice(`Parsing custom sorting specification SUCCEEDED!`)
} else {
if (anySortingSpecFound) {
errorMessage = errorMessage ? errorMessage : `No valid '${SORTINGSPEC_YAML_KEY}:' key(s) in YAML front matter or multiline YAML indentation error or general YAML syntax error`
} else {
errorMessage = `No custom sorting specification found or only empty specification(s)`
}
new Notice(`Parsing custom sorting specification FAILED. Suspending the plugin.\n${errorMessage}`, ERROR_NOTICE_TIMEOUT)
this.showNotice(`Parsing custom sorting specification FAILED. Suspending the plugin.\n${errorMessage}`, ERROR_NOTICE_TIMEOUT)
this.settings.suspended = true
this.saveSettings()
}
@ -110,13 +118,13 @@ export default class CustomSortPlugin extends Plugin {
this.saveSettings()
let iconToSet: string
if (this.settings.suspended) {
new Notice('Custom sort OFF');
this.showNotice('Custom sort OFF');
this.sortSpecCache = null
iconToSet = ICON_SORT_SUSPENDED
} else {
this.readAndParseSortingSpec();
if (this.sortSpecCache) {
new Notice('Custom sort ON');
this.showNotice('Custom sort ON');
this.initialAutoOrManualSortingTriggered = true
iconToSet = ICON_SORT_ENABLED_ACTIVE
} else {
@ -180,7 +188,7 @@ export default class CustomSortPlugin extends Plugin {
this.readAndParseSortingSpec()
this.initialAutoOrManualSortingTriggered = true
if (this.sortSpecCache) { // successful read of sorting specifications?
new Notice('Custom sort ON')
this.showNotice('Custom sort ON')
const fileExplorerView: FileExplorerView = this.getFileExplorer()
if (fileExplorerView) {
setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_ACTIVE)
@ -342,5 +350,18 @@ class CustomSortSettingTab extends PluginSettingTab {
}
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Enable notifications of plugin state changes')
.setDesc('The plugin can show notifications about its state changes: e.g. when successfully parsed and applied'
+ ' the custom sorting specification, or, when the parsing failed. If the notifications are disabled,'
+ ' the only indicator of plugin state is the ribbon button icon. The developer console presents the parsing'
+ ' error messages regardless if the notifications are enabled or not.')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.notificationsEnabled)
.onChange(async (value) => {
this.plugin.settings.notificationsEnabled = value;
await this.plugin.saveSettings();
}));
}
}

View File

@ -5,5 +5,6 @@
"0.6.1": "0.12.0",
"0.6.2": "0.12.0",
"0.7.0": "0.15.0",
"0.7.1": "0.15.0"
"0.7.1": "0.15.0",
"0.7.2": "0.15.0"
}