diff --git a/src/main.ts b/src/main.ts index 08bf53f..a0a750b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -256,7 +256,7 @@ export default class SendNotePlugin extends Plugin { if (shareLink) { // The note is already shared, copy the link to the clipboard await navigator.clipboard.writeText(shareLink); - new StatusMessage("📋 Shared link copied to clipboard"); + new StatusMessage("📋 Shared link copied to clipboard", StatusType.Default, 2000); } else { // The note is not already shared, share it first and copy the link to the clipboard await this.uploadNote(false, true); @@ -271,7 +271,7 @@ export default class SendNotePlugin extends Plugin { "Delete shared note?", "Are you sure you want to delete this shared note and the shared link? This will not delete your local note.", async () => { - new StatusMessage("Deleting note..."); + new StatusMessage("Deleting note...", StatusType.Default, 2000); // await this.api.deleteSharedNote(sharedFile.url); await this.deletePaste(this.getIdentifier(sharedFile.url)); @@ -322,7 +322,7 @@ export default class SendNotePlugin extends Plugin { setIcon(copyIcon, "copy"); copyIcon.onclick = async () => { await navigator.clipboard.writeText(shareLink); - new StatusMessage("📋 Sending link copied to clipboard"); + new StatusMessage("📋 Sending link copied to clipboard", StatusType.Default, 2000); }; // Delete shared note icon const deleteIcon = iconsEl.createEl("span"); @@ -371,38 +371,11 @@ export default class SendNotePlugin extends Plugin { }) ) .then((data) => { - console.log("data", data); + new StatusMessage(`Deleted note: ${data.Deleted?.[0]?.Key}`, StatusType.Default, 2000); }) .catch((err) => { console.log("error", err); }); - // const url = "https://pastebin.com/api/api_post.php"; - - // const formData = new URLSearchParams(); - // // formData.append("api_dev_key", this.settings.pastebinApiKey); - // // formData.append("api_user_key", this.settings.pastebinUserKey); - // formData.append("api_paste_key", pasteKey); - // formData.append("api_option", "delete"); - - // try { - // const response = await requestUrl({ - // url: url, - // method: "POST", - // headers: { - // "Content-Type": "application/x-www-form-urlencoded", - // }, - // body: formData.toString(), - // }); - - // const result = await response.text; - - // if (result.trim() === "Paste Removed") { - // } else { - // console.error("Error deleting paste:", result); - // } - // } catch (error) { - // console.error("Network or parsing error:", error); - // } } private generateRandomString(length = 5) { diff --git a/src/note.ts b/src/note.ts index 6ca6c74..8a6fd8f 100644 --- a/src/note.ts +++ b/src/note.ts @@ -94,22 +94,9 @@ export default class Note { } }); - // const pastebinData = { - // api_dev_key: this.plugin.settings.pastebinApiKey, - // api_user_key: this.plugin.settings.pastebinUserKey, - // api_option: "paste", - // api_paste_private: 1, - // api_paste_name: this.file.basename, - // api_paste_expire_date: this.plugin.settings.pastebinExpiry, - // api_paste_format: "text", - // api_paste_code: encodeURIComponent(noteContent), - // }; - - // const body = this.createQueryString(pastebinData); this.plugin .uploadFile(noteContent, this.file.basename) .then((res) => { - console.log(res); const responseText = res.trim(); if (!responseText.startsWith("http")) { throw new Error("Invalid URL response from AWS"); @@ -123,7 +110,6 @@ export default class Note { } else { obsidianUrl = `obsidian://send-note?sendurl=${responseText}&filename=${this.file.basename}.md&encrypted=true&key=${encryptionKey}`; } - // console.log(obsidianUrl); navigator.clipboard.writeText(obsidianUrl); this.plugin.app.fileManager.processFrontMatter(this.file, (frontmatter) => { if ((frontmatter["send_link"] = true)) { @@ -135,47 +121,6 @@ export default class Note { .catch((err) => { console.error(err); }); - - // requestUrl({ - // url: "https://pastebin.com/api/api_post.php", - // method: "POST", - // headers: { - // "Content-Type": "application/x-www-form-urlencoded", - // }, - // body: body, - // }) - // .then((res) => { - // const responseText = res.text.trim(); - // if (!responseText.startsWith("http")) { - // throw new Error("Invalid URL response from Pastebin"); - // } - // const urlObj = new URL(responseText); - // const pathSegments = urlObj.pathname.split("/"); - // const suffix = pathSegments[pathSegments.length - 1]; - // let obsidianUrl = ""; - // if (shareUnencrypted) { - // obsidianUrl = `obsidian://send-note?sendurl=https://pastebin.com/raw/${suffix}&filename=${this.file.basename}.md`; - // } else { - // obsidianUrl = `obsidian://send-note?sendurl=https://pastebin.com/raw/${suffix}&filename=${this.file.basename}.md&encrypted=true&key=${encryptionKey}`; - // } - // // console.log(obsidianUrl); - // navigator.clipboard.writeText(obsidianUrl); - // this.plugin.app.fileManager.processFrontMatter(this.file, (frontmatter) => { - // if ((frontmatter["send_link"] = true)) { - // frontmatter["send_link"] = obsidianUrl; - // } - // }); - // this.plugin.addShareIcons(); - // }) - // .catch((err) => { - // console.log("err", err); - // this.status = new StatusMessage( - // err + - // ". The note uploading failed. If you got status 422, it might be because you have exceeded your allowed number of pastes for 24 hours.", - // StatusType.Error, - // 5 * 1000 - // ); - // }); return; }