diff --git a/CHANGELOG.md b/CHANGELOG.md index 844d866..4a14ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to Rich Foot will be documented in this file. +## [1.5.1] - 2024-10-31 + +### Fixed +- Fixed bug where excluded folders were not being saved correctly + ## [1.5.0] - 2024-10-31 ### Added diff --git a/UPDATE.md b/UPDATE.md index b094b72..3098edd 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -1,5 +1,8 @@ ## 🎉 What's New +### v1.5.1 +- Fixed bug where excluded folders were not being saved correctly + ### v1.5.0 #### New Customization Options Rich Foot now offers extensive customization options for fine-tuning the appearance of your note footers: diff --git a/example-vault.zip b/example-vault.zip index 8b678b3..3905971 100644 Binary files a/example-vault.zip and b/example-vault.zip differ diff --git a/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/data.json b/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/data.json index ac5b39f..5a0a8fa 100644 --- a/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/data.json +++ b/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/data.json @@ -12,5 +12,5 @@ "showBacklinks": true, "showOutlinks": true, "showDates": true, - "lastVersion": "1.4.0" + "lastVersion": "1.5.0" } \ No newline at end of file diff --git a/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/main.js b/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/main.js index 1fb5bb0..ab8a977 100644 --- a/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/main.js +++ b/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/main.js @@ -78,7 +78,7 @@ var ReleaseNotesModal = class extends import_obsidian.Modal { }; // virtual-module:virtual:release-notes -var releaseNotes = "

\u{1F389} What's New

\n

v1.5.0

\n

New Customization Options

\n

Rich Foot now offers extensive customization options for fine-tuning the appearance of your note footers:

\n
Border Controls
\n\n
Link Appearance
\n\n
Date Display
\n\n"; +var releaseNotes = "

\u{1F389} What's New

\n

v1.5.1

\n\n

v1.5.0

\n

New Customization Options

\n

Rich Foot now offers extensive customization options for fine-tuning the appearance of your note footers:

\n
Border Controls
\n\n
Link Appearance
\n\n
Date Display
\n\n"; // src/main.js var DEFAULT_SETTINGS = { @@ -88,7 +88,8 @@ var DEFAULT_SETTINGS = { borderRadius: 15, datesOpacity: 1, linksOpacity: 1, - showReleaseNotes: true + showReleaseNotes: true, + excludedFolders: [] }; var RichFootPlugin = class extends import_obsidian2.Plugin { async onload() { @@ -120,7 +121,11 @@ var RichFootPlugin = class extends import_obsidian2.Plugin { this.contentObserver = new MutationObserver(this.updateRichFoot); } async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); + const loadedData = await this.loadData(); + this.settings = Object.assign({}, DEFAULT_SETTINGS, loadedData); + if (!Array.isArray(this.settings.excludedFolders)) { + this.settings.excludedFolders = []; + } } async saveSettings() { await this.saveData(this.settings); @@ -315,6 +320,10 @@ var RichFootPlugin = class extends import_obsidian2.Plugin { } // Add this method to check if a file should be excluded shouldExcludeFile(filePath) { + var _a; + if (!((_a = this.settings) == null ? void 0 : _a.excludedFolders)) { + return false; + } return this.settings.excludedFolders.some((folder) => filePath.startsWith(folder)); } }; @@ -324,6 +333,7 @@ var RichFootSettingTab = class extends import_obsidian2.PluginSettingTab { this.plugin = plugin; } display() { + var _a; let { containerEl } = this; containerEl.empty(); containerEl.addClass("rich-foot-settings"); @@ -334,19 +344,21 @@ var RichFootSettingTab = class extends import_obsidian2.PluginSettingTab { cls: "setting-item-description" }); const excludedFoldersContainer = containerEl.createDiv("excluded-folders-container"); - this.plugin.settings.excludedFolders.forEach((folder, index) => { - const folderDiv = excludedFoldersContainer.createDiv("excluded-folder-item"); - folderDiv.createSpan({ text: folder }); - const deleteButton = folderDiv.createEl("button", { - text: "Delete", - cls: "excluded-folder-delete" + if ((_a = this.plugin.settings) == null ? void 0 : _a.excludedFolders) { + this.plugin.settings.excludedFolders.forEach((folder, index) => { + const folderDiv = excludedFoldersContainer.createDiv("excluded-folder-item"); + folderDiv.createSpan({ text: folder }); + const deleteButton = folderDiv.createEl("button", { + text: "Delete", + cls: "excluded-folder-delete" + }); + deleteButton.addEventListener("click", async () => { + this.plugin.settings.excludedFolders.splice(index, 1); + await this.plugin.saveSettings(); + this.display(); + }); }); - deleteButton.addEventListener("click", async () => { - this.plugin.settings.excludedFolders.splice(index, 1); - await this.plugin.saveSettings(); - this.display(); - }); - }); + } const newFolderSetting = new import_obsidian2.Setting(containerEl).setName("Add excluded folder").setDesc("Enter a folder path or browse to select").addText((text) => text.setPlaceholder("folder/subfolder").onChange(() => { })).addButton((button) => button.setButtonText("Browse").onClick(async () => { const folder = await this.browseForFolder(); diff --git a/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/manifest.json b/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/manifest.json index 387ea66..5706193 100644 --- a/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/manifest.json +++ b/example-vault/rich-foot-example/.obsidian/plugins/rich-foot/manifest.json @@ -1,7 +1,7 @@ { "id": "rich-foot", "name": "Rich Foot", - "version": "1.5.0", + "version": "1.5.1", "minAppVersion": "1.6.0", "description": "Adds backlink tags and created/modified dates to the footer of your notes.", "author": "Justin Parker", diff --git a/example-vault/rich-foot-example/.obsidian/workspace.json b/example-vault/rich-foot-example/.obsidian/workspace.json index 73b9083..2bb88c6 100644 --- a/example-vault/rich-foot-example/.obsidian/workspace.json +++ b/example-vault/rich-foot-example/.obsidian/workspace.json @@ -166,12 +166,12 @@ "active": "e2b1b7584f7a474c", "lastOpenFiles": [ "backlink test.md", + "exclude/no rich-feet here.md", + "exclude/me too/no rich-feet here either.md", "🦶 Rich Foot.md", "images/rich-feet-3.jpg", "images/rich-feet.jpg", "images/rich-feet-2.jpg", - "exclude/me too/no rich-feet here either.md", - "exclude/no rich-feet here.md", "images", "exclude/me too", "exclude", diff --git a/manifest.json b/manifest.json index 387ea66..5706193 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "rich-foot", "name": "Rich Foot", - "version": "1.5.0", + "version": "1.5.1", "minAppVersion": "1.6.0", "description": "Adds backlink tags and created/modified dates to the footer of your notes.", "author": "Justin Parker", diff --git a/src/main.js b/src/main.js index ca650ca..ed3aa8d 100644 --- a/src/main.js +++ b/src/main.js @@ -9,7 +9,8 @@ const DEFAULT_SETTINGS = { borderRadius: 15, datesOpacity: 1, linksOpacity: 1, - showReleaseNotes: true + showReleaseNotes: true, + excludedFolders: [] }; class RichFootSettings { @@ -74,7 +75,13 @@ class RichFootPlugin extends Plugin { } async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); + const loadedData = await this.loadData(); + this.settings = Object.assign({}, DEFAULT_SETTINGS, loadedData); + + // Ensure excludedFolders is always an array + if (!Array.isArray(this.settings.excludedFolders)) { + this.settings.excludedFolders = []; + } } async saveSettings() { @@ -325,6 +332,9 @@ class RichFootPlugin extends Plugin { // Add this method to check if a file should be excluded shouldExcludeFile(filePath) { + if (!this.settings?.excludedFolders) { + return false; + } return this.settings.excludedFolders.some(folder => filePath.startsWith(folder)); } } @@ -353,21 +363,23 @@ class RichFootSettingTab extends PluginSettingTab { const excludedFoldersContainer = containerEl.createDiv('excluded-folders-container'); // Display current excluded folders - this.plugin.settings.excludedFolders.forEach((folder, index) => { - const folderDiv = excludedFoldersContainer.createDiv('excluded-folder-item'); - folderDiv.createSpan({ text: folder }); - - const deleteButton = folderDiv.createEl('button', { - text: 'Delete', - cls: 'excluded-folder-delete' - }); - - deleteButton.addEventListener('click', async () => { - this.plugin.settings.excludedFolders.splice(index, 1); - await this.plugin.saveSettings(); - this.display(); // Refresh the display + if (this.plugin.settings?.excludedFolders) { + this.plugin.settings.excludedFolders.forEach((folder, index) => { + const folderDiv = excludedFoldersContainer.createDiv('excluded-folder-item'); + folderDiv.createSpan({ text: folder }); + + const deleteButton = folderDiv.createEl('button', { + text: 'Delete', + cls: 'excluded-folder-delete' + }); + + deleteButton.addEventListener('click', async () => { + this.plugin.settings.excludedFolders.splice(index, 1); + await this.plugin.saveSettings(); + this.display(); + }); }); - }); + } // Add new folder section const newFolderSetting = new Setting(containerEl)