mirror of
https://github.com/idanlib/ObsidianFastForwardLinkPlugin.git
synced 2026-07-22 11:30:28 +00:00
add feature to remove redirects folder and contents upon plugin unload
This commit is contained in:
parent
a0d6c86521
commit
67edb89f41
1 changed files with 15 additions and 2 deletions
17
main.ts
17
main.ts
|
|
@ -98,19 +98,32 @@ export default class RedirectPlugin extends Plugin {
|
|||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log(redirectingNote);
|
||||
new Notice(
|
||||
`${redirectingNote.name} is already in the _redirects folder.`,
|
||||
3000
|
||||
);
|
||||
}
|
||||
|
||||
// MAKE SURE TO NOT REMOVE THE REDIRECTING NOTE WHEN CLICKED INSIDE THE _REDIRECTS FOLDER!
|
||||
// console.log(redirectingNote.path);
|
||||
// console.log(`_redirects/${redirectingNote.name}`);
|
||||
if (redirectingNote.path === `_redirects/${redirectingNote.name}`) {
|
||||
// console.log("yes we're in the reidrects folder");
|
||||
console.log("yes we're in the reidrects folder");
|
||||
return;
|
||||
}
|
||||
await this.app.vault.delete(redirectingNote);
|
||||
}
|
||||
|
||||
onunload() {}
|
||||
onunload() {
|
||||
const redirectsFolder = this.app.vault.getFolderByPath("_redirects");
|
||||
|
||||
if (!redirectsFolder) {
|
||||
return;
|
||||
}
|
||||
console.log("redirectsFolder: ", redirectsFolder);
|
||||
|
||||
this.app.vault.delete(redirectsFolder, true);
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign(
|
||||
|
|
|
|||
Loading…
Reference in a new issue