2020-01-26 14:56:59 +00:00
|
|
|
const constants = require("../constants")
|
2020-01-29 15:20:20 +00:00
|
|
|
const {proxyImage, proxyVideo} = require("../utils/proxyurl")
|
2020-01-26 14:56:59 +00:00
|
|
|
|
|
|
|
class TimelineBaseMethods {
|
|
|
|
constructor() {
|
|
|
|
/** @type {import("../types").GraphChildAll & {owner?: any}} */
|
|
|
|
this.data
|
|
|
|
}
|
|
|
|
|
|
|
|
getType() {
|
|
|
|
if (this.data.__typename === "GraphImage") {
|
|
|
|
if (this.data.owner) return constants.symbols.TYPE_IMAGE
|
|
|
|
else return constants.symbols.TYPE_GALLERY_IMAGE
|
|
|
|
} else if (this.data.__typename === "GraphVideo") {
|
|
|
|
if (this.data.owner) return constants.symbols.TYPE_VIDEO
|
|
|
|
else return constants.symbols.TYPE_GALLERY_VIDEO
|
|
|
|
} else if (this.data.__typename === "GraphSidecar") {
|
|
|
|
return constants.symbols.TYPE_GALLERY
|
|
|
|
} else {
|
|
|
|
throw new Error("Unknown shortcode __typename: "+this.data.__typename)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-29 15:20:20 +00:00
|
|
|
isVideo() {
|
|
|
|
return this.data.__typename === "GraphVideo"
|
|
|
|
}
|
|
|
|
|
2020-01-26 14:56:59 +00:00
|
|
|
getDisplayUrlP() {
|
|
|
|
return proxyImage(this.data.display_url)
|
|
|
|
}
|
|
|
|
|
2020-01-29 15:20:20 +00:00
|
|
|
getVideoUrlP() {
|
|
|
|
return proxyVideo(this.data.video_url)
|
|
|
|
}
|
|
|
|
|
2020-01-26 14:56:59 +00:00
|
|
|
getAlt() {
|
|
|
|
return this.data.accessibility_caption || "No image description available."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = TimelineBaseMethods
|