-5
models.js
-5
models.js
···
306
306
return this.author?.handle.endsWith('.ap.brid.gy');
307
307
}
308
308
309
-
/** @returns {boolean} */
310
-
get isTruncatedFediPost() {
311
-
return this.isFediPost && (this.text.endsWith('…') || this.text.endsWith('[…]'));
312
-
}
313
-
314
309
/** @returns {string | undefined} */
315
310
get originalFediContent() {
316
311
return this.record.bridgyOriginalText;
-41
post_component.js
-41
post_component.js
···
287
287
}
288
288
}
289
289
290
-
if (this.post.isTruncatedFediPost) {
291
-
if (this.post.embed && ('url' in this.post.embed) && typeof this.post.embed.url == 'string') {
292
-
let link = this.buildLoadFediPostLink(this.post.embed.url, p);
293
-
p.append(' ', link);
294
-
}
295
-
}
296
-
297
290
return p;
298
291
}
299
292
···
331
324
}
332
325
333
326
return stats;
334
-
}
335
-
336
-
/** @param {string} originalURL, @param {HTMLElement} p, @returns {AnyElement} */
337
-
338
-
buildLoadFediPostLink(originalURL, p) {
339
-
let link = $tag('a', {
340
-
href: originalURL,
341
-
text: "(Load full post)"
342
-
});
343
-
344
-
link.addEventListener('click', (e) => {
345
-
e.preventDefault();
346
-
link.remove();
347
-
348
-
this.loadFediPost(originalURL, p);
349
-
});
350
-
351
-
return link;
352
327
}
353
328
354
329
/** @returns {AnyElement} */
···
558
533
559
534
// TODO
560
535
Array.from(div.querySelectorAll('a.link-card')).forEach(x => x.remove());
561
-
}
562
-
}
563
-
564
-
/** @param {string} url, @param {HTMLElement} p, @returns Promise<void> */
565
-
566
-
async loadFediPost(url, p) {
567
-
let host = new URL(url).host;
568
-
let postId = url.replace(/\/$/, '').split('/').reverse()[0];
569
-
let statusURL = `https://${host}/api/v1/statuses/${postId}`;
570
-
571
-
let response = await fetch(statusURL);
572
-
let json = await response.json();
573
-
574
-
if (json.content) {
575
-
let div = $tag('div.body', { html: sanitizeHTML(json.content) });
576
-
p.replaceWith(div);
577
536
}
578
537
}
579
538