From 12d9cd2b91400574334ecf7bc40e06234cc7953a Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Thu, 2 Mar 2023 19:21:02 +0100 Subject: [PATCH 1/2] Fix premieres on the subscription page --- src/renderer/components/ft-list-video/ft-list-video.js | 2 +- src/renderer/views/Subscriptions/Subscriptions.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index 7afe052fa25d6..598e0f816620c 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -463,7 +463,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, diff --git a/src/renderer/views/Subscriptions/Subscriptions.js b/src/renderer/views/Subscriptions/Subscriptions.js index 48a896d566c46..f18f88adb3730 100644 --- a/src/renderer/views/Subscriptions/Subscriptions.js +++ b/src/renderer/views/Subscriptions/Subscriptions.js @@ -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) } From 765f282ec4b66d2fabed010db65df1e3b0cce251 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Fri, 3 Mar 2023 20:00:17 +0100 Subject: [PATCH 2/2] Fix date when restoring from subscription cache --- src/renderer/components/ft-list-video/ft-list-video.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index 598e0f816620c..5e1b17776ed95 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -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 {