Add missing plugin objects

This commit is contained in:
Lost Paul 2024-02-03 16:52:51 +01:00
parent f37a9d7a83
commit ca194f7172
2 changed files with 15 additions and 13 deletions

View file

@ -1,28 +1,30 @@
import { TAbstractFile, TFolder, TFile } from 'obsidian';
import FolderNotesPlugin from 'src/main';
import { getFolderNote, getFolder } from 'src/functions/folderNoteFunctions';
import { removeCSSClassFromEL, addCSSClassToTitleEL } from 'src/functions/styleFunctions';
import { getFolderPathFromString } from 'src/functions/utils';
export function handleDelete(file: TAbstractFile, plugin: FolderNotesPlugin) {
const folder = this.app.vault.getAbstractFileByPath(this.getFolderPathFromString(file.path));
const folder = plugin.app.vault.getAbstractFileByPath(getFolderPathFromString(file.path));
if (folder instanceof TFolder) {
if (this.isEmptyFolderNoteFolder(folder)) {
this.addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
if (plugin.isEmptyFolderNoteFolder(folder)) {
addCSSClassToTitleEL(folder.path, 'only-has-folder-note');
} else if (folder.children.length == 0 || folder.children.length > 1) {
this.removeCSSClassFromEL(folder.path, 'only-has-folder-note');
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
}
}
if (file instanceof TFile) {
const folder = getFolder(this, file);
const folder = getFolder(plugin, file);
if (!folder) { return; }
this.removeCSSClassFromEL(folder.path, 'has-folder-note');
this.removeCSSClassFromEL(folder.path, 'only-has-folder-note');
removeCSSClassFromEL(folder.path, 'has-folder-note');
removeCSSClassFromEL(folder.path, 'only-has-folder-note');
}
if (!(file instanceof TFolder)) { return; }
const folderNote = getFolderNote(this, file.path);
const folderNote = getFolderNote(plugin, file.path);
if (!folderNote) { return; }
this.removeCSSClassFromEL(folderNote.path, 'is-folder-note');
if (!this.settings.syncDelete) { return; }
this.app.vault.delete(folderNote);
removeCSSClassFromEL(folderNote.path, 'is-folder-note');
if (!plugin.settings.syncDelete) { return; }
plugin.app.vault.delete(folderNote);
}

View file

@ -32,10 +32,10 @@ export function handleRename(file: TAbstractFile, oldPath: string, plugin: Folde
if (file instanceof TFolder) {
plugin.tabManager.updateTab(file.path);
return handleFolderRename(file, oldPath, this);
return handleFolderRename(file, oldPath, plugin);
} else if (file instanceof TFile) {
return handleFileRename(file, oldPath, this);
return handleFileRename(file, oldPath, plugin);
}
}