This commit is contained in:
SebastianMC 2024-06-10 22:35:28 +02:00
parent 4bae4fe37e
commit 3bc307c121
1 changed files with 12 additions and 3 deletions

View File

@ -232,7 +232,6 @@ export default class CustomSortPlugin extends Plugin {
if (this.sortSpecCache) { if (this.sortSpecCache) {
if (fileExplorerView) { if (fileExplorerView) {
this.showNotice('Custom sort ON'); this.showNotice('Custom sort ON');
this.initialAutoOrManualSortingTriggered = true
iconToSet = ICON_SORT_ENABLED_ACTIVE iconToSet = ICON_SORT_ENABLED_ACTIVE
} else { } else {
this.showNotice('Custom sort GENERAL PROBLEM. See console for detailed message.'); this.showNotice('Custom sort GENERAL PROBLEM. See console for detailed message.');
@ -256,6 +255,7 @@ export default class CustomSortPlugin extends Plugin {
if (fileExplorerView) { if (fileExplorerView) {
if (this.fileExplorerFolderPatched) { if (this.fileExplorerFolderPatched) {
fileExplorerView.requestSort(); fileExplorerView.requestSort();
this.initialAutoOrManualSortingTriggered = true
} }
} else { } else {
if (iconToSet === ICON_SORT_ENABLED_ACTIVE) { if (iconToSet === ICON_SORT_ENABLED_ACTIVE) {
@ -326,14 +326,23 @@ export default class CustomSortPlugin extends Plugin {
if (!this.settings.suspended) { if (!this.settings.suspended) {
if (!this.initialAutoOrManualSortingTriggered) { if (!this.initialAutoOrManualSortingTriggered) {
this.readAndParseSortingSpec() this.readAndParseSortingSpec()
this.initialAutoOrManualSortingTriggered = true
if (this.sortSpecCache) { // successful read of sorting specifications? if (this.sortSpecCache) { // successful read of sorting specifications?
this.showNotice('Custom sort ON') this.showNotice('Custom sort ON')
const fileExplorerView: FileExplorerView | undefined = this.checkFileExplorerIsAvailableAndPatchable(false) let fileExplorerView: FileExplorerView | undefined = this.checkFileExplorerIsAvailableAndPatchable(false)
if (fileExplorerView && !this.fileExplorerFolderPatched) {
this.fileExplorerFolderPatched = this.patchFileExplorerFolder(fileExplorerView);
if (!this.fileExplorerFolderPatched) {
fileExplorerView = undefined
}
}
if (fileExplorerView) { if (fileExplorerView) {
setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_ACTIVE) setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_ACTIVE)
fileExplorerView.requestSort() fileExplorerView.requestSort()
this.initialAutoOrManualSortingTriggered = true
} else { } else {
// Remark: in this case the File Explorer will render later on with standard Obsidian sort
// and a different event will be responsible for patching it and applying the custom sort
setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_NOT_APPLIED) setIcon(this.ribbonIconEl, ICON_SORT_ENABLED_NOT_APPLIED)
plugin.ribbonIconStateInaccurate = true plugin.ribbonIconStateInaccurate = true
} }