From 69585a18ec561f2225f7cab09eefe27206678776 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Mon, 20 Apr 2020 19:51:53 +1200 Subject: [PATCH] Show followers not available message instead of 0 --- src/site/api/routes.js | 3 ++- src/site/pug/user.pug | 13 ++++++++----- src/site/sass/main.sass | 11 +++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/site/api/routes.js b/src/site/api/routes.js index d5ceb6e..29be478 100644 --- a/src/site/api/routes.js +++ b/src/site/api/routes.js @@ -68,8 +68,9 @@ module.exports = [ if (typeof page === "number" && !isNaN(page) && page >= 1) { await user.timeline.fetchUpToPage(page - 1) } + const followerCountsAvailable = !(user.constructor.name === "ReelUser" && user.following === 0 && user.followedBy === 0) const {website_origin, settings: {display_feed_validation_buttons}} = constants - return render(200, "pug/user.pug", {url, user, constants, website_origin, display_feed_validation_buttons}) + return render(200, "pug/user.pug", {url, user, followerCountsAvailable, constants, website_origin, display_feed_validation_buttons}) }).catch(error => { if (error === constants.symbols.NOT_FOUND || error === constants.symbols.ENDPOINT_OVERRIDDEN) { return render(404, "pug/friendlyerror.pug", { diff --git a/src/site/pug/user.pug b/src/site/pug/user.pug index 5fccdd7..35b9961 100644 --- a/src/site/pug/user.pug +++ b/src/site/pug/user.pug @@ -1,4 +1,4 @@ -//- Needs user, url, constants, website_origin, display_feed_validation_buttons +//- Needs user, followerCountsAvailable, url, constants, website_origin, display_feed_validation_buttons include includes/timeline_page.pug include includes/next_page_button.pug @@ -50,10 +50,13 @@ html a(href=user.data.external_url)= user.data.external_url if user.posts != undefined div.profile-counter #[span(data-numberformat=user.posts).count #{numberFormat(user.posts)}] posts - if user.following != undefined - div.profile-counter #[span(data-numberformat=user.following).count #{numberFormat(user.following)}] following - if user.followedBy != undefined - div.profile-counter #[span(data-numberformat=user.followedBy).count #{numberFormat(user.followedBy)}] followed by + if followerCountsAvailable + if user.following != undefined + div.profile-counter #[span(data-numberformat=user.following).count #{numberFormat(user.following)}] following + if user.followedBy != undefined + div.profile-counter #[span(data-numberformat=user.followedBy).count #{numberFormat(user.followedBy)}] followed by + else + div.profile-counter.not-available Followers not available. div.links if constants.settings.rss_enabled +feed_link("RSS", "rss", user.data.username, "application/rss+xml", display_feed_validation_buttons) diff --git a/src/site/sass/main.sass b/src/site/sass/main.sass index e85914a..43a6f49 100644 --- a/src/site/sass/main.sass +++ b/src/site/sass/main.sass @@ -87,20 +87,26 @@ body font-weight: normal .bio + margin: 20px 0px unicode-bidi: plaintext .profile-counter line-height: 1.3 + &.not-available + font-style: italic + .count font-weight: bold .website + margin: 20px 0px + a, a:visited color: $main-theme-link-color .links - margin-top: 20px + margin: 15px 0px display: flex flex-wrap: wrap justify-content: center @@ -114,9 +120,6 @@ body > * margin: 5px - > *:last-child - margin-bottom: 10px // because padding-bottom on parent doesn't seem to work. - .timeline --image-size: 260px $image-size: var(--image-size)