mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-22 12:21:37 +00:00
Support loading shortcodes of a single image
This commit is contained in:
parent
d660c84941
commit
91022aa5da
7 changed files with 136 additions and 22 deletions
|
|
@ -5,10 +5,10 @@ const {compile} = require("pug")
|
|||
require("../testimports")(collectors)
|
||||
|
||||
const rssImageTemplate = compile(`
|
||||
img(src=constants.website_origin+entry.getDisplayUrlP() alt=entry.getAlt() width=entry.data.dimensions.width height=entry.data.dimensions.height)
|
||||
img(src=constants.website_origin+entry.getDisplayUrlP() alt=entry.getAlt() width=entry.data.dimensions && entry.data.dimensions.width height=entry.data.dimensions && entry.data.dimensions.height)
|
||||
`)
|
||||
const rssVideoTemplate = compile(`
|
||||
video(src=constants.website_origin+entry.getVideoUrlP() controls preload="auto" width=entry.data.dimensions.width height=entry.data.dimensions.height)
|
||||
video(src=constants.website_origin+entry.getVideoUrlP() controls preload="auto" width=entry.data.dimensions && entry.data.dimensions.width height=entry.data.dimensions && entry.data.dimensions.height)
|
||||
`)
|
||||
|
||||
class TimelineChild extends TimelineBaseMethods {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ each child in children
|
|||
class TimelineEntry extends TimelineBaseMethods {
|
||||
constructor() {
|
||||
super()
|
||||
this.fullyUpdated = false
|
||||
/** @type {import("../types").TimelineEntryAll} some properties may not be available yet! */
|
||||
// @ts-ignore
|
||||
this.data = {}
|
||||
|
|
@ -38,12 +39,16 @@ class TimelineEntry extends TimelineBaseMethods {
|
|||
}
|
||||
|
||||
async update() {
|
||||
return collectors.fetchShortcodeData(this.data.shortcode).then(data => {
|
||||
this.applyN3(data.result)
|
||||
}).catch(error => {
|
||||
console.error("TimelineEntry could not self-update; trying to continue anyway...")
|
||||
console.error("E:", error)
|
||||
})
|
||||
if (!this.fullyUpdated) {
|
||||
return collectors.fetchShortcodeData(this.data.shortcode).then(data => {
|
||||
this.applyN3(data.result)
|
||||
}).catch(error => {
|
||||
console.error("TimelineEntry could not self-update; trying to continue anyway...")
|
||||
console.error("E:", error)
|
||||
}).finally(() => {
|
||||
this.fullyUpdated = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,6 +93,7 @@ class TimelineEntry extends TimelineBaseMethods {
|
|||
* All mutations should act exactly once and have no effect on already mutated data.
|
||||
*/
|
||||
fixData() {
|
||||
this.hasDate = !!this.data.taken_at_timestamp
|
||||
this.date = new Date(this.data.taken_at_timestamp*1000)
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +243,7 @@ class TimelineEntry extends TimelineBaseMethods {
|
|||
let fromCache = true
|
||||
const clone = await (async () => {
|
||||
// Do we just already have the extended owner?
|
||||
if (this.data.owner.full_name) { // this property is on extended owner and not basic owner
|
||||
if (this.data.owner.profile_pic_url) { // this property is on extended owner and not basic owner
|
||||
const clone = proxyExtendedOwner(this.data.owner)
|
||||
this.ownerPfpCacheP = clone.profile_pic_url
|
||||
return clone
|
||||
|
|
@ -246,7 +252,7 @@ class TimelineEntry extends TimelineBaseMethods {
|
|||
else if (collectors.userRequestCache.getByID(this.data.owner.id)) {
|
||||
/** @type {import("./User")} */
|
||||
const user = collectors.userRequestCache.getByID(this.data.owner.id)
|
||||
if (user.data.full_name !== undefined) {
|
||||
if (user.data.profile_pic_url !== undefined) {
|
||||
this.data.owner = {
|
||||
id: user.data.id,
|
||||
username: user.data.username,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue