mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-13 09:28:50 +01:00
No need render div if no content
This commit is contained in:
parent
810596b7cf
commit
f98306ed18
1 changed files with 58 additions and 56 deletions
|
@ -1370,63 +1370,65 @@ function Status({
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div class="content" ref={contentRef} data-read-more={readMoreText}>
|
{!!content && (
|
||||||
<div
|
<div class="content" ref={contentRef} data-read-more={readMoreText}>
|
||||||
lang={language}
|
<div
|
||||||
dir="auto"
|
lang={language}
|
||||||
class="inner-content"
|
dir="auto"
|
||||||
onClick={handleContentLinks({
|
class="inner-content"
|
||||||
mentions,
|
onClick={handleContentLinks({
|
||||||
instance,
|
mentions,
|
||||||
previewMode,
|
instance,
|
||||||
statusURL: url,
|
previewMode,
|
||||||
})}
|
statusURL: url,
|
||||||
dangerouslySetInnerHTML={{
|
})}
|
||||||
__html: enhanceContent(content, {
|
dangerouslySetInnerHTML={{
|
||||||
emojis,
|
__html: enhanceContent(content, {
|
||||||
postEnhanceDOM: (dom) => {
|
emojis,
|
||||||
// Remove target="_blank" from links
|
postEnhanceDOM: (dom) => {
|
||||||
dom
|
// Remove target="_blank" from links
|
||||||
.querySelectorAll('a.u-url[target="_blank"]')
|
dom
|
||||||
.forEach((a) => {
|
.querySelectorAll('a.u-url[target="_blank"]')
|
||||||
if (!/http/i.test(a.innerText.trim())) {
|
.forEach((a) => {
|
||||||
a.removeAttribute('target');
|
if (!/http/i.test(a.innerText.trim())) {
|
||||||
}
|
|
||||||
});
|
|
||||||
if (previewMode) return;
|
|
||||||
// Unfurl Mastodon links
|
|
||||||
Array.from(
|
|
||||||
dom.querySelectorAll(
|
|
||||||
'a[href]:not(.u-url):not(.mention):not(.hashtag)',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.filter((a) => {
|
|
||||||
const url = a.href;
|
|
||||||
const isPostItself =
|
|
||||||
url === status.url || url === status.uri;
|
|
||||||
return !isPostItself && isMastodonLinkMaybe(url);
|
|
||||||
})
|
|
||||||
.forEach((a, i) => {
|
|
||||||
unfurlMastodonLink(currentInstance, a.href).then(
|
|
||||||
(result) => {
|
|
||||||
if (!result) return;
|
|
||||||
a.removeAttribute('target');
|
a.removeAttribute('target');
|
||||||
if (!sKey) return;
|
}
|
||||||
if (!Array.isArray(states.statusQuotes[sKey])) {
|
});
|
||||||
states.statusQuotes[sKey] = [];
|
if (previewMode) return;
|
||||||
}
|
// Unfurl Mastodon links
|
||||||
if (!states.statusQuotes[sKey][i]) {
|
Array.from(
|
||||||
states.statusQuotes[sKey].splice(i, 0, result);
|
dom.querySelectorAll(
|
||||||
}
|
'a[href]:not(.u-url):not(.mention):not(.hashtag)',
|
||||||
},
|
),
|
||||||
);
|
)
|
||||||
});
|
.filter((a) => {
|
||||||
},
|
const url = a.href;
|
||||||
}),
|
const isPostItself =
|
||||||
}}
|
url === status.url || url === status.uri;
|
||||||
/>
|
return !isPostItself && isMastodonLinkMaybe(url);
|
||||||
<QuoteStatuses id={id} instance={instance} level={quoted} />
|
})
|
||||||
</div>
|
.forEach((a, i) => {
|
||||||
|
unfurlMastodonLink(currentInstance, a.href).then(
|
||||||
|
(result) => {
|
||||||
|
if (!result) return;
|
||||||
|
a.removeAttribute('target');
|
||||||
|
if (!sKey) return;
|
||||||
|
if (!Array.isArray(states.statusQuotes[sKey])) {
|
||||||
|
states.statusQuotes[sKey] = [];
|
||||||
|
}
|
||||||
|
if (!states.statusQuotes[sKey][i]) {
|
||||||
|
states.statusQuotes[sKey].splice(i, 0, result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<QuoteStatuses id={id} instance={instance} level={quoted} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{!!poll && (
|
{!!poll && (
|
||||||
<Poll
|
<Poll
|
||||||
lang={language}
|
lang={language}
|
||||||
|
|
Loading…
Reference in a new issue