Skip to content

Build your personal knowledge base with Trilium Notes

code cleanup

alteistb42fd1a6c52e
diff --git a/background.js b/background.js
index 49f94eaf4f..b4ac88bdf1 100644
--- a/background.js
+++ b/background.js
@@ -303,11 +303,9 @@ async function saveTabs() {
return;
}
- toast(
- `${tabs.length} links have been saved to Trilium.`,
- resp.noteId,
- tabs.map(tab=>{return tab.id})
- );
+ const tabIds = tabs.map(tab=>{return tab.id});
+
+ toast(`${tabs.length} links have been saved to Trilium.`, resp.noteId, tabIds);
}
browser.contextMenus.onClicked.addListener(async function(info, tab) {
diff --git a/content.js b/content.js
index 326323b008..25048685d8 100644
--- a/content.js
+++ b/content.js
@@ -209,14 +209,15 @@ function getImages(container) {
return images;
}
-function createLink(clickMessage, text, color = "lightskyblue") {
+function createLink(clickAction, text, color = "lightskyblue") {
const link = document.createElement('a');
link.href = "javascript:";
link.style.color = color;
link.appendChild(document.createTextNode(text));
link.addEventListener("click", () => {
- browser.runtime.sendMessage(null, clickMessage)
+ browser.runtime.sendMessage(null, clickAction)
});
+
return link
}
@@ -230,20 +231,19 @@ async function prepareMessageResponse(message) {
messageText = document.createElement('p');
messageText.setAttribute("style", "padding: 0; margin: 0")
messageText.appendChild(document.createTextNode(message.message + " "));
- openNoteLink = createLink(
- {name: 'openNoteInTrilium',noteId: message.noteId},
+ messageText.appendChild(createLink(
+ {name: 'openNoteInTrilium', noteId: message.noteId},
"Open in Trilium."
- )
- messageText.appendChild(openNoteLink);
+ ));
+ // only after saving tabs
if (message.tabIds) {
messageText.appendChild(document.createElement("br"));
- closeTabsLink = createLink(
+ messageText.appendChild(createLink(
{name: 'closeTabs', tabIds: message.tabIds},
"Close saved tabs.",
"tomato"
- )
- messageText.appendChild(closeTabsLink);
+ ));
}
}
else {