mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-13 23:16:46 +00:00
feat: enhance reply handling in posts
Refactor to improve handling of reply links within posts by introducing a dedicated function, ensuring more accurate and consistent URL modifications. This enhancement simplifies future maintenance and scalability of the codebase.
This commit is contained in:
@@ -83,6 +83,19 @@ function getLinkPreview($, item, { staticProxy, index }) {
|
||||
return $.html(link)
|
||||
}
|
||||
|
||||
function getReply($, item, { channel }) {
|
||||
const reply = $(item).find('.tgme_widget_message_reply')
|
||||
reply?.wrapInner('<small></small>')?.wrapInner('<blockquote></blockquote>')
|
||||
|
||||
const href = reply?.attr('href')
|
||||
if (href) {
|
||||
const url = new URL(href)
|
||||
reply?.attr('href', `${url.pathname}`.replace(channel, 'posts'))
|
||||
}
|
||||
|
||||
return $.html(reply)
|
||||
}
|
||||
|
||||
function modifyHTMLContent($, content, { index } = {}) {
|
||||
$(content).find('.emoji')?.attr('style', '')
|
||||
$(content).find('a')?.each((_index, a) => {
|
||||
@@ -117,7 +130,7 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
|
||||
tags,
|
||||
text: content?.text(),
|
||||
content: [
|
||||
$.html($(item).find('.tgme_widget_message_reply')?.wrapInner('<small></small>')?.wrapInner('<blockquote></blockquote>')),
|
||||
getReply($, item, { channel }),
|
||||
getImages($, item, { staticProxy, id, index, title }),
|
||||
getVideo($, item, { staticProxy, id, index, title }),
|
||||
getAudio($, item, { staticProxy, id, index, title }),
|
||||
|
||||
Reference in New Issue
Block a user