From 9f0f98e21ec9a612c5987881c3e5e30f952e5dec Mon Sep 17 00:00:00 2001 From: Rogerio Chaves Date: Sun, 26 Apr 2020 19:16:19 +0200 Subject: [PATCH] Show communities on others profiles, both on mobile and desktop --- app/lib/express.js | 17 +++++++++++++++-- app/lib/mobile-routes.js | 10 +++++++++- app/views/mobile/profile.ejs | 16 ++++++++++++++++ app/views/profile.ejs | 13 +++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/app/lib/express.js b/app/lib/express.js index d77edc3..5a446eb 100644 --- a/app/lib/express.js +++ b/app/lib/express.js @@ -310,14 +310,27 @@ router.get( return res.redirect("/"); } - const [profile, posts, friends, friendshipStatus] = await Promise.all([ + const [ + profile, + posts, + friends, + friendshipStatus, + communities, + ] = await Promise.all([ queries.getProfile(id), queries.getPosts({ id }), queries.getFriends({ id }), queries.getFriendshipStatus(req.context.profile.id, id), + queries.getProfileCommunities(id), ]); - res.render("profile", { profile, posts, friends, friendshipStatus }); + res.render("profile", { + profile, + posts, + friends, + friendshipStatus, + communities, + }); } ); diff --git a/app/lib/mobile-routes.js b/app/lib/mobile-routes.js index 6732121..447d8a1 100644 --- a/app/lib/mobile-routes.js +++ b/app/lib/mobile-routes.js @@ -54,11 +54,18 @@ module.exports.setupRoutes = (router) => { return res.redirect("/mobile"); } - const [profile, posts, friends, friendshipStatus] = await Promise.all([ + const [ + profile, + posts, + friends, + friendshipStatus, + communities, + ] = await Promise.all([ queries.getProfile(id), queries.getPosts({ id }), queries.getFriends({ id }), queries.getFriendshipStatus(req.context.profile.id, id), + queries.getProfileCommunities(id), ]); res.render("mobile/profile", { @@ -66,6 +73,7 @@ module.exports.setupRoutes = (router) => { posts, friends, friendshipStatus, + communities, layout: "mobile/_layout", }); } diff --git a/app/views/mobile/profile.ejs b/app/views/mobile/profile.ejs index 7a4debc..7ef02e0 100644 --- a/app/views/mobile/profile.ejs +++ b/app/views/mobile/profile.ejs @@ -29,6 +29,9 @@ +
@@ -50,5 +53,18 @@
+
\ No newline at end of file diff --git a/app/views/profile.ejs b/app/views/profile.ejs index 4aa878d..ed92028 100644 --- a/app/views/profile.ejs +++ b/app/views/profile.ejs @@ -54,6 +54,19 @@

Friends

<%- include('_friends', { friends: friends.friends }) %> + <% if (friends.friends.length == 0) { %> +

No friends

+ <% } %> + +

Communities

+ <% communities.map(community => { %> + + #<%= community %> + + <% }) %> + <% if (communities.length == 0) { %> +

No communities

+ <% } %>