mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Merge pull request #301 from mjkerrison/fix/excluded-folders-reset-293
fix: prevent excluded folders list from being reset
This commit is contained in:
commit
5908ff0b79
5 changed files with 18 additions and 13 deletions
|
|
@ -40,7 +40,7 @@ export default class WhitelistedFoldersSettings extends Modal {
|
||||||
this.plugin.settingsTab, contentEl, whitelistedFolder,
|
this.plugin.settingsTab, contentEl, whitelistedFolder,
|
||||||
);
|
);
|
||||||
addWhitelistedFolder(this.plugin, whitelistedFolder);
|
addWhitelistedFolder(this.plugin, whitelistedFolder);
|
||||||
this.settingsTab.display();
|
this.settingsTab.renderSettingsPage(this.settingsTab.plugin.settings.settingsTab);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ export async function deleteFolderNote(
|
||||||
if (!folder) return;
|
if (!folder) return;
|
||||||
|
|
||||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter(
|
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter(
|
||||||
(excludedFolder) => (excludedFolder.path !== folder.path) && excludedFolder.showFolderNote);
|
(excludedFolder) => (excludedFolder.path !== folder.path) || !excludedFolder.showFolderNote);
|
||||||
plugin.saveSettings(false);
|
plugin.saveSettings(false);
|
||||||
|
|
||||||
removeCSSClassFromFileExplorerEL(folder.path, 'has-folder-note', false, plugin);
|
removeCSSClassFromFileExplorerEL(folder.path, 'has-folder-note', false, plugin);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ import type FolderOverviewPlugin from 'src/obsidian-folder-overview/src/main';
|
||||||
* @description Refreshes the CSS classes for all folder notes in the file explorer.
|
* @description Refreshes the CSS classes for all folder notes in the file explorer.
|
||||||
*/
|
*/
|
||||||
export function refreshAllFolderStyles(forceReload = false, plugin: FolderNotesPlugin): void {
|
export function refreshAllFolderStyles(forceReload = false, plugin: FolderNotesPlugin): void {
|
||||||
if (plugin.activeFileExplorer === getFileExplorer(plugin) && !forceReload) { return; }
|
const fileExplorer = getFileExplorer(plugin);
|
||||||
plugin.activeFileExplorer = getFileExplorer(plugin);
|
if (!fileExplorer) { return; }
|
||||||
|
if (plugin.activeFileExplorer === fileExplorer && !forceReload) { return; }
|
||||||
|
plugin.activeFileExplorer = fileExplorer;
|
||||||
plugin.app.vault.getAllLoadedFiles().forEach(async (file) => {
|
plugin.app.vault.getAllLoadedFiles().forEach(async (file) => {
|
||||||
if (file instanceof TFolder) {
|
if (file instanceof TFolder) {
|
||||||
await updateCSSClassesForFolder(file.path, plugin);
|
await updateCSSClassesForFolder(file.path, plugin);
|
||||||
|
|
@ -226,7 +228,7 @@ export function showFolderNoteInFileExplorer(path: string, plugin: FolderNotesPl
|
||||||
|
|
||||||
export function hideFolderNoteInFileExplorer(folderPath: string, plugin: FolderNotesPlugin): void {
|
export function hideFolderNoteInFileExplorer(folderPath: string, plugin: FolderNotesPlugin): void {
|
||||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter(
|
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter(
|
||||||
(folder) => (folder.path !== folderPath) && folder.showFolderNote);
|
(folder) => (folder.path !== folderPath) || !folder.showFolderNote);
|
||||||
plugin.saveSettings(false);
|
plugin.saveSettings(false);
|
||||||
removeCSSClassFromFileExplorerEL(folderPath, 'show-folder-note-in-explorer', true, plugin);
|
removeCSSClassFromFileExplorerEL(folderPath, 'show-folder-note-in-explorer', true, plugin);
|
||||||
updateCSSClassesForFolder(folderPath, plugin);
|
updateCSSClassesForFolder(folderPath, plugin);
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,17 @@ export function getParentFolderPath(path: string): string {
|
||||||
|
|
||||||
export function getFileExplorer(
|
export function getFileExplorer(
|
||||||
plugin: FolderNotesPlugin | FolderOverviewPlugin,
|
plugin: FolderNotesPlugin | FolderOverviewPlugin,
|
||||||
): FileExplorerWorkspaceLeaf {
|
): FileExplorerWorkspaceLeaf | undefined {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
let leaf = plugin.app.workspace.getLeavesOfType('file-explorer')[0] as unknown as FileExplorerWorkspaceLeaf;
|
let leaf = plugin.app.workspace.getLeavesOfType('file-explorer')[0] as unknown as FileExplorerWorkspaceLeaf;
|
||||||
|
|
||||||
|
if (!leaf) { return undefined; }
|
||||||
|
|
||||||
/* make.md plugin integration */
|
/* make.md plugin integration */
|
||||||
if (leaf.containerEl.lastChild.dataset.type == 'mk-path-view') {
|
if ((leaf.containerEl?.lastChild as HTMLElement)?.dataset?.type == 'mk-path-view') {
|
||||||
plugin.app.workspace.iterateAllLeaves((x) => {
|
plugin.app.workspace.iterateAllLeaves((x) => {
|
||||||
if (x.tabHeaderEl.dataset.type == 'file-explorer') {
|
if ((x as FileExplorerWorkspaceLeaf).tabHeaderEl?.dataset?.type == 'file-explorer') {
|
||||||
leaf = x;
|
leaf = x as FileExplorerWorkspaceLeaf;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -58,12 +60,13 @@ export function getFileExplorer(
|
||||||
return leaf;
|
return leaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFileExplorerView(plugin: FolderNotesPlugin): FileExplorerView {
|
export function getFileExplorerView(plugin: FolderNotesPlugin): FileExplorerView | undefined {
|
||||||
return getFileExplorer(plugin).view;
|
return getFileExplorer(plugin)?.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFocusedItem(plugin: FolderNotesPlugin): TreeNode<FileTreeItem> | null {
|
export function getFocusedItem(plugin: FolderNotesPlugin): TreeNode<FileTreeItem> | null {
|
||||||
const fileExplorer = getFileExplorer(plugin) as unknown as FileExplorerLeaf;
|
const fileExplorer = getFileExplorer(plugin) as unknown as FileExplorerLeaf | undefined;
|
||||||
|
if (!fileExplorer) { return null; }
|
||||||
const { focusedItem } = fileExplorer.view.tree;
|
const { focusedItem } = fileExplorer.view.tree;
|
||||||
return focusedItem;
|
return focusedItem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ export async function renderExcludeFolders(settingsTab: SettingsTab): Promise<vo
|
||||||
);
|
);
|
||||||
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
||||||
addExcludedFolder(settingsTab.plugin, excludedFolder);
|
addExcludedFolder(settingsTab.plugin, excludedFolder);
|
||||||
settingsTab.display();
|
settingsTab.renderSettingsPage(settingsTab.plugin.settings.settingsTab);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue