Skip to content

Commit

Permalink
resolve excluded folders save issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Nov 1, 2024
1 parent 12163fd commit 4626cb1
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Binary file modified example-vault.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"showBacklinks": true,
"showOutlinks": true,
"showDates": true,
"lastVersion": "1.4.0"
"lastVersion": "1.5.0"
}
42 changes: 27 additions & 15 deletions example-vault/rich-foot-example/.obsidian/plugins/rich-foot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var ReleaseNotesModal = class extends import_obsidian.Modal {
};

// virtual-module:virtual:release-notes
var releaseNotes = "<h2>\u{1F389} What&#39;s New</h2>\n<h3>v1.5.0</h3>\n<h4>New Customization Options</h4>\n<p>Rich Foot now offers extensive customization options for fine-tuning the appearance of your note footers:</p>\n<h5>Border Controls</h5>\n<ul>\n<li>Adjustable border width (1-10px)</li>\n<li>Multiple border styles (solid, dashed, dotted, double, groove, ridge, inset, outset)</li>\n<li>Border opacity control (0-1)</li>\n</ul>\n<h5>Link Appearance</h5>\n<ul>\n<li>Customizable border radius for links (0-15px)</li>\n<li>Opacity control for backlinks and outlinks (0-1)</li>\n</ul>\n<h5>Date Display</h5>\n<ul>\n<li>Adjustable opacity for created/modified dates (0-1)</li>\n</ul>\n";
var releaseNotes = "<h2>\u{1F389} What&#39;s New</h2>\n<h3>v1.5.1</h3>\n<ul>\n<li>Fixed bug where excluded folders were not being saved correctly</li>\n</ul>\n<h3>v1.5.0</h3>\n<h4>New Customization Options</h4>\n<p>Rich Foot now offers extensive customization options for fine-tuning the appearance of your note footers:</p>\n<h5>Border Controls</h5>\n<ul>\n<li>Adjustable border width (1-10px)</li>\n<li>Multiple border styles (solid, dashed, dotted, double, groove, ridge, inset, outset)</li>\n<li>Border opacity control (0-1)</li>\n</ul>\n<h5>Link Appearance</h5>\n<ul>\n<li>Customizable border radius for links (0-15px)</li>\n<li>Opacity control for backlinks and outlinks (0-1)</li>\n</ul>\n<h5>Date Display</h5>\n<ul>\n<li>Adjustable opacity for created/modified dates (0-1)</li>\n</ul>\n";

// src/main.js
var DEFAULT_SETTINGS = {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
};
Expand All @@ -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");
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions example-vault/rich-foot-example/.obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
44 changes: 28 additions & 16 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const DEFAULT_SETTINGS = {
borderRadius: 15,
datesOpacity: 1,
linksOpacity: 1,
showReleaseNotes: true
showReleaseNotes: true,
excludedFolders: []
};

class RichFootSettings {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4626cb1

Please sign in to comment.