1
0
Fork 0
mirror of https://github.com/cheeaun/phanpy.git synced 2025-04-04 23:53:46 +03:00

Only threadify & unfurl non-reblog post object

This commit is contained in:
Lim Chee Aun 2024-01-04 18:56:11 +08:00
parent d25c2df392
commit c0987209a8

View file

@ -192,19 +192,14 @@ export function saveStatus(status, instance, opts) {
// THREAD TRAVERSER // THREAD TRAVERSER
if (!skipThreading) { if (!skipThreading) {
queueMicrotask(() => { queueMicrotask(() => {
threadifyStatus(status, instance); threadifyStatus(status.reblog || status, instance);
if (status.reblog) {
queueMicrotask(() => {
threadifyStatus(status.reblog, instance);
});
}
}); });
} }
// UNFURLER // UNFURLER
if (!skipUnfurling) { if (!skipUnfurling) {
queueMicrotask(() => { queueMicrotask(() => {
unfurlStatus(status, instance); unfurlStatus(status.reblog || status, instance);
}); });
} }
} }
@ -253,10 +248,10 @@ export const threadifyStatus = rateLimit(_threadifyStatus, 100);
const fauxDiv = document.createElement('div'); const fauxDiv = document.createElement('div');
export function unfurlStatus(status, instance) { export function unfurlStatus(status, instance) {
const { instance: currentInstance } = api(); const { instance: currentInstance } = api();
const content = status.reblog?.content || status.content; const content = status?.content;
const hasLink = /<a/i.test(content); const hasLink = /<a/i.test(content);
if (hasLink) { if (hasLink) {
const sKey = statusKey(status?.reblog?.id || status?.id, instance); const sKey = statusKey(status?.id, instance);
fauxDiv.innerHTML = content; fauxDiv.innerHTML = content;
const links = fauxDiv.querySelectorAll( const links = fauxDiv.querySelectorAll(
'a[href]:not(.u-url):not(.mention):not(.hashtag)', 'a[href]:not(.u-url):not(.mention):not(.hashtag)',