refactor open bookmark

This commit is contained in:
quenousimporte 2024-01-08 11:50:27 +01:00
parent d065c41686
commit 63286cd4ec
1 changed files with 7 additions and 9 deletions

16
main.js
View File

@ -321,14 +321,7 @@ function browsebookmarks()
{
var bookmarks = JSON.parse(getnote("bookmarks").content);
searchinlist(bookmarks.map(b => b.title))
.then(title =>
{
var url = bookmarks
.find(b => b.title == title)
.url;
window.open(url, "_blank");
});
.then(openbookmark);
}
function purgetodo()
@ -1639,6 +1632,11 @@ function titlewithtags(note)
return text;
}
function openbookmark(title)
{
window.open(JSON.parse(getnote("bookmarks").content).find(b => b.title == title).url, "_blank");
}
function commandpalette()
{
searchinlist(commands
@ -1699,7 +1697,7 @@ function commandpalette()
}
else if (selected.prefix == "open bookmark ")
{
window.open(JSON.parse(getnote("bookmarks").content).find(b => b.title == selected.text).url, "_blank");
openbookmark(selected.text);
}
else
{