use find instead of filter

This commit is contained in:
Dmitriy Pleshevskiy 2023-07-01 13:37:06 +03:00
parent fd706d7d29
commit b85b65dda0
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985

View file

@ -57,8 +57,8 @@ function getMessageUrl(msg) {
} }
function getTextLink(msg) { function getTextLink(msg) {
const textLinks = (msg.entities ?? []).filter(isTextLink); const textLink = (msg.entities ?? []).find(isTextLink);
return textLinks.length ? textLinks[0].url : null; return textLink ? textLink.url : null;
} }
function isTextLink(msgEntity) { function isTextLink(msgEntity) {