mirror of https://github.com/FreeTubeApp/FreeTube
Fix premieres on the subscription page (#3240)
* Fix premieres on the subscription page * Fix date when restoring from subscription cache
This commit is contained in:
parent
43eefb458f
commit
667ee83130
|
@ -417,7 +417,13 @@ export default defineComponent({
|
|||
this.viewCount = this.data.viewCount
|
||||
|
||||
if (typeof this.data.premiereDate !== 'undefined') {
|
||||
this.publishedText = this.data.premiereDate.toLocaleString()
|
||||
let premiereDate = this.data.premiereDate
|
||||
|
||||
// premiereDate will be a string when the subscriptions are restored from the cache
|
||||
if (typeof premiereDate === 'string') {
|
||||
premiereDate = new Date(premiereDate)
|
||||
}
|
||||
this.publishedText = premiereDate.toLocaleString()
|
||||
} else if (typeof (this.data.premiereTimestamp) !== 'undefined') {
|
||||
this.publishedText = new Date(this.data.premiereTimestamp * 1000).toLocaleString()
|
||||
} else {
|
||||
|
@ -463,7 +469,7 @@ export default defineComponent({
|
|||
// Using `Math.ceil` so that -1.x days ago displayed as 1 day ago
|
||||
// Notice that the value is turned to negative to be displayed as "ago"
|
||||
this.uploadedTime = new Intl.RelativeTimeFormat(this.currentLocale).format(Math.ceil(-timeDiffFromNow), timeUnit)
|
||||
} else if (typeof (this.data.publishedText) !== 'undefined' && this.data.publishedText !== null && !this.isLive) {
|
||||
} else if (this.publishedText && !this.isLive) {
|
||||
// produces a string according to the template in the locales string
|
||||
this.uploadedTime = toLocalePublicationString({
|
||||
publishText: this.publishedText,
|
||||
|
|
|
@ -282,6 +282,8 @@ export default defineComponent({
|
|||
videos.map(video => {
|
||||
if (video.liveNow) {
|
||||
video.publishedDate = new Date().getTime()
|
||||
} else if (video.isUpcoming) {
|
||||
video.publishedDate = video.premiereDate
|
||||
} else {
|
||||
video.publishedDate = calculatePublishedDate(video.publishedText)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue