Show communities on others profiles, both on mobile and desktop

This commit is contained in:
Rogerio Chaves 2020-04-26 19:16:19 +02:00
parent e6ce416dce
commit 9f0f98e21e
No known key found for this signature in database
GPG Key ID: E6AF5440509B1D94
4 changed files with 53 additions and 3 deletions

View File

@ -310,14 +310,27 @@ router.get(
return res.redirect("/"); return res.redirect("/");
} }
const [profile, posts, friends, friendshipStatus] = await Promise.all([ const [
profile,
posts,
friends,
friendshipStatus,
communities,
] = await Promise.all([
queries.getProfile(id), queries.getProfile(id),
queries.getPosts({ id }), queries.getPosts({ id }),
queries.getFriends({ id }), queries.getFriends({ id }),
queries.getFriendshipStatus(req.context.profile.id, 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,
});
} }
); );

View File

@ -54,11 +54,18 @@ module.exports.setupRoutes = (router) => {
return res.redirect("/mobile"); 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.getProfile(id),
queries.getPosts({ id }), queries.getPosts({ id }),
queries.getFriends({ id }), queries.getFriends({ id }),
queries.getFriendshipStatus(req.context.profile.id, id), queries.getFriendshipStatus(req.context.profile.id, id),
queries.getProfileCommunities(id),
]); ]);
res.render("mobile/profile", { res.render("mobile/profile", {
@ -66,6 +73,7 @@ module.exports.setupRoutes = (router) => {
posts, posts,
friends, friends,
friendshipStatus, friendshipStatus,
communities,
layout: "mobile/_layout", layout: "mobile/_layout",
}); });
} }

View File

@ -29,6 +29,9 @@
<button class="tab-title js-tab-button"> <button class="tab-title js-tab-button">
Friends Friends
</button> </button>
<button class="tab-title js-tab-button">
Communities
</button>
</div> </div>
<div class="tab-content"> <div class="tab-content">
<div class="tab-item js-tab-item"> <div class="tab-item js-tab-item">
@ -50,5 +53,18 @@
</div> </div>
<div class="tab-item js-tab-item" style="display: none; padding: 10px"> <div class="tab-item js-tab-item" style="display: none; padding: 10px">
<%- include('_friends', { friends: friends.friends }) %> <%- include('_friends', { friends: friends.friends }) %>
<% if (friends.friends.length == 0) { %>
<p>No friends</p>
<% } %>
</div>
<div class="tab-item js-tab-item" style="display: none; padding: 10px">
<% communities.map(community => { %>
<a href="/communities/<%= community %>" class="link-block">
#<%= community %>
</a>
<% }) %>
<% if (communities.length == 0) { %>
<p>No communities</p>
<% } %>
</div> </div>
</div> </div>

View File

@ -54,6 +54,19 @@
<div class="friends-communities"> <div class="friends-communities">
<h2>Friends</h2> <h2>Friends</h2>
<%- include('_friends', { friends: friends.friends }) %> <%- include('_friends', { friends: friends.friends }) %>
<% if (friends.friends.length == 0) { %>
<p>No friends</p>
<% } %>
<h2 style="margin-top: 30px">Communities</h2>
<% communities.map(community => { %>
<a href="/communities/<%= community %>" class="link-block">
#<%= community %>
</a>
<% }) %>
<% if (communities.length == 0) { %>
<p>No communities</p>
<% } %>
</div> </div>
</div> </div>