mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix handle create event
This commit is contained in:
parent
404eeac1e8
commit
18593d252e
4 changed files with 16 additions and 8 deletions
|
|
@ -6,12 +6,12 @@ import { removeCSSClassFromEL, addCSSClassToTitleEL } from 'src/functions/styleF
|
|||
|
||||
export function handleCreate(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
||||
if (!plugin.app.workspace.layoutReady) return;
|
||||
|
||||
|
||||
const folder = file.parent;
|
||||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
|
||||
} else if (folder.children.length == 0 || folder.children.length > 1) {
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
}
|
||||
}
|
||||
|
|
@ -20,9 +20,13 @@ export function handleCreate(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
|||
const folder = getFolder(plugin, file);
|
||||
if (!(folder instanceof TFolder)) { return; }
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (!folderNote) { return; }
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note');
|
||||
addCSSClassToTitleEL(file.path, 'is-folder-note');
|
||||
|
||||
if (folderNote && folderNote.path === file.path) {
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note');
|
||||
addCSSClassToTitleEL(file.path, 'is-folder-note');
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
if (!plugin.app.workspace.layoutReady) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export function handleDelete(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
|||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
|
||||
} else if (folder.children.length == 0 || folder.children.length > 1) {
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@ export function handleDelete(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
|||
if (file instanceof TFile) {
|
||||
const folder = getFolder(plugin, file);
|
||||
if (!folder) { return; }
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (folderNote) { return; }
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note');
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function handleRename(file: TAbstractFile, oldPath: string, plugin: Folde
|
|||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
|
||||
} else if (folder.children.length == 0 || folder.children.length > 1) {
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ export function handleRename(file: TAbstractFile, oldPath: string, plugin: Folde
|
|||
if (oldFolder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(oldFolder)) {
|
||||
addCSSClassToTitleEL(oldFolder.path, 'only-has-folder-note');
|
||||
} else if (oldFolder.children.length == 0 || oldFolder.children.length > 1) {
|
||||
} else {
|
||||
removeCSSClassFromEL(oldFolder.path, 'only-has-folder-note');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ export function loadFileClasses(forceReload = false, plugin: FolderNotesPlugin)
|
|||
addCSSClassToTitleEL(file.path, 'has-folder-note');
|
||||
if (plugin.isEmptyFolderNoteFolder(file)) {
|
||||
addCSSClassToTitleEL(file.path, 'only-has-folder-note');
|
||||
} else {
|
||||
removeCSSClassFromEL(file.path, 'only-has-folder-note');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue