mirror of
https://github.com/idanlib/ObsidianFastForwardLinkPlugin.git
synced 2026-07-22 11:30:28 +00:00
Merge pull request #21 from IdanLib/rewrite-move-to-forwards-folder-with-file-manager-api
improvements
This commit is contained in:
commit
98e43c3002
2 changed files with 5 additions and 8 deletions
|
|
@ -49,7 +49,7 @@ export default class RedirectSettingsTab extends PluginSettingTab {
|
|||
button.setButtonText("Delete");
|
||||
button.setTooltip("Delete the _forwards folder.");
|
||||
button.setWarning();
|
||||
button.onClick((evt) => {
|
||||
button.onClick(async (evt) => {
|
||||
const forwardsFolder =
|
||||
this.app.vault.getFolderByPath("_forwards");
|
||||
if (!forwardsFolder) {
|
||||
|
|
@ -61,7 +61,7 @@ export default class RedirectSettingsTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
try {
|
||||
this.app.vault.delete(forwardsFolder, true);
|
||||
await this.app.fileManager.trashFile(forwardsFolder);
|
||||
new Notice(
|
||||
"_forwards folder deleted successfully.",
|
||||
2000
|
||||
|
|
|
|||
9
main.ts
9
main.ts
|
|
@ -110,8 +110,6 @@ export default class RedirectPlugin extends Plugin {
|
|||
private async moveRedirectNote(
|
||||
redirectingNote: TFile | null
|
||||
): Promise<TFile | void> {
|
||||
let redirectingNoteInFolder = null;
|
||||
|
||||
if (!redirectingNote) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -121,7 +119,7 @@ export default class RedirectPlugin extends Plugin {
|
|||
}
|
||||
|
||||
try {
|
||||
redirectingNoteInFolder = await this.app.vault.copy(
|
||||
const redirectingNoteInFolder = await this.app.vault.copy(
|
||||
redirectingNote,
|
||||
`/_forwards/${redirectingNote.name}`
|
||||
);
|
||||
|
|
@ -131,11 +129,10 @@ export default class RedirectPlugin extends Plugin {
|
|||
this.app.workspace.off("file-open", this.redirectRef);
|
||||
|
||||
await this.app.workspace
|
||||
.getLeaf(this.settings.openInNewTab)
|
||||
.getLeaf()
|
||||
.openFile(redirectingNoteInFolder, {
|
||||
active: this.settings.switchToNewTab,
|
||||
});
|
||||
this.app.workspace.getLeaf().detach();
|
||||
|
||||
this.app.workspace.on("file-open", this.redirectRef);
|
||||
}
|
||||
|
|
@ -148,7 +145,7 @@ export default class RedirectPlugin extends Plugin {
|
|||
|
||||
private async deleteNote(orgRedirectingNote: TFile): Promise<void> {
|
||||
try {
|
||||
await this.app.vault.delete(orgRedirectingNote);
|
||||
await this.app.fileManager.trashFile(orgRedirectingNote);
|
||||
} catch (error) {
|
||||
new Notice(
|
||||
"Failed to delete directing note from original location. Please delete manually.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue