From 5f036124d9e138c2b9927031614b26d9f8f9e97c Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 19 Jan 2021 02:23:25 +1300 Subject: [PATCH] Fix IGTV loading and post count --- src/lib/structures/Timeline.js | 18 +++++++++++++++--- src/site/pug/user.pug | 6 +++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/lib/structures/Timeline.js b/src/lib/structures/Timeline.js index 1e444f4..bf1e070 100644 --- a/src/lib/structures/Timeline.js +++ b/src/lib/structures/Timeline.js @@ -29,8 +29,15 @@ class Timeline { this.type = type /** @type {import("./TimelineEntry")[][]} */ this.pages = [] - if (this.user.data.edge_owner_to_timeline_media) { - this.addPage(this.user.data.edge_owner_to_timeline_media) + this.entryCount = 0 + if (this.type === "timeline") { + if (this.user.data.edge_owner_to_timeline_media) { + this.addPage(this.user.data.edge_owner_to_timeline_media) + } + } else if (this.type === "igtv") { + if (this.user.data.edge_felix_video_timeline) { + this.addPage(this.user.data.edge_felix_video_timeline) + } } } @@ -75,7 +82,12 @@ class Timeline { // add the page this.pages.push(transformEdges(page.edges)) this.page_info = page.page_info - this.user.posts = page.count + // update self post count + this.entryCount = page.count + // update user post count + if (this.type === "timeline") { + this.user.posts = page.count + } } async fetchFeed() { diff --git a/src/site/pug/user.pug b/src/site/pug/user.pug index 61eb2b9..28effd8 100644 --- a/src/site/pug/user.pug +++ b/src/site/pug/user.pug @@ -71,9 +71,9 @@ html if userURL p.website a(href=userURL)= userURL - if user.posts != undefined + if selectedTimeline.entryCount != undefined div.profile-counter - | #[span(data-numberformat=user.posts).count #{numberFormat(user.posts)} ] + | #[span(data-numberformat=selectedTimeline.entryCount).count #{numberFormat(selectedTimeline.entryCount)} ] = ll.post_counter_label if followerCountsAvailable if user.following != undefined @@ -104,7 +104,7 @@ html .timeline-section(dir=ll.meta_direction) .selector-container +selector-button(ll.tab_timeline, "timeline", "") - if user.data.has_channel !== false + if user.data.has_channel !== false || user.data.edge_felix_video_timeline.count !== 0 +selector-button(ll.tab_igtv, "igtv", "/channel") main(class=hasPosts ? "" : "no-posts")#timeline.timeline