diff --git a/app/lib/express.js b/app/lib/express.js index 847c9aa..444fdde 100644 --- a/app/lib/express.js +++ b/app/lib/express.js @@ -562,11 +562,28 @@ router.post("/about", async (req, res) => { }); router.get("/communities", async (req, res) => { + if (isPhone(req)) { + return res.redirect(`/mobile/communities`); + } + const communities = await queries.getCommunities(ssbServer); res.render("communities/list", { communities }); }); +router.get("/mobile/communities", async (req, res) => { + const communities = await queries.getCommunities(ssbServer); + + if (!isPhone(req)) { + return res.redirect(`/communities`); + } + + res.render("mobile/communities/list", { + communities, + layout: "mobile/_layout", + }); +}); + const communityData = (req) => { const name = req.params.name; return queries.getCommunityMembers(ssbServer, name).then((members) => ({ @@ -578,6 +595,10 @@ const communityData = (req) => { router.get("/communities/:name", async (req, res) => { const name = req.params.name; + if (isPhone(req)) { + return res.redirect(`/mobile/communities/${name}`); + } + const [community, posts] = await Promise.all([ communityData(req), queries.getCommunityPosts(ssbServer, name), @@ -590,6 +611,22 @@ router.get("/communities/:name", async (req, res) => { }); }); +router.get("/mobile/communities/:name", async (req, res) => { + const name = req.params.name; + + if (!isPhone(req)) { + return res.redirect(`/communities/${name}`); + } + + const posts = await queries.getCommunityPosts(ssbServer, name); + + res.render("mobile/communities/community", { + community: { name }, + posts, + layout: "mobile/_layout", + }); +}); + router.get("/communities/:name/new", async (req, res) => { const community = await communityData(req); diff --git a/app/public/js/desktop.js b/app/public/js/desktop.js index b89dc9e..f349a03 100644 --- a/app/public/js/desktop.js +++ b/app/public/js/desktop.js @@ -80,7 +80,7 @@ composeButtons.forEach((composeButton) => { let url = composeButton.dataset.url; let body = "message=" + encodeURIComponent(messageInput.value); - if (parent.querySelector(".js-secret-recipients")) { + if (parent.querySelector(".js-recipients-list")) { const recipients = selectedRecipients(); if (recipients.length == 0) return; diff --git a/app/public/js/mobile.js b/app/public/js/mobile.js index 674cd38..52794e8 100644 --- a/app/public/js/mobile.js +++ b/app/public/js/mobile.js @@ -105,7 +105,7 @@ composeButtons.forEach((composeButton) => { let url = composeButton.dataset.url; let body = "message=" + encodeURIComponent(messageInput.value); - if (parent.querySelector(".js-secret-recipients")) { + if (parent.querySelector(".js-recipients-list")) { const recipients = selectedRecipients(); if (recipients.length == 0) return; diff --git a/app/public/mobile_style.css b/app/public/mobile_style.css index da7f3bf..a8eb114 100644 --- a/app/public/mobile_style.css +++ b/app/public/mobile_style.css @@ -95,6 +95,14 @@ nav a.selected { padding: 0; } +.secret-chat.no-secrets { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + align-content: center; +} + .secret-button { padding: 8px 14px; font-size: 16px; @@ -104,7 +112,14 @@ nav a.selected { margin-right: 12px; } -.new-secret-button { +a.compose-new-button { + display: flex; + align-items: center; + justify-content: center; + text-decoration: none; +} + +.compose-new-button { position: fixed; bottom: 95px; width: 65px; @@ -118,7 +133,7 @@ nav a.selected { color: #684510; } -.new-secret-button:hover { +.compose-new-button:hover { background: #fb1; } @@ -146,3 +161,11 @@ nav a.selected { border-bottom: none; height: 33px; } + +.community-topic-link { + padding: 10px; +} + +.friends-communities { + border-radius: 0; +} diff --git a/app/public/style.css b/app/public/style.css index 2615080..1b0e3f3 100644 --- a/app/public/style.css +++ b/app/public/style.css @@ -373,3 +373,11 @@ h2 { .community-topic-link:hover .community-topic-name { text-decoration: underline; } + +.community-topic-name { + width: calc(100% - 110px); +} + +.community-topic-replies { + width: 110px; +} diff --git a/app/views/communities/community.ejs b/app/views/communities/community.ejs index 3b1432d..aa70855 100644 --- a/app/views/communities/community.ejs +++ b/app/views/communities/community.ejs @@ -7,6 +7,6 @@
<%= topicTitle(post.value) %>
-
💬 <%= post.value.replies.length %> replies
+
💬 <%= post.value.replies.length %> replies
<% }) %> \ No newline at end of file diff --git a/app/views/home.ejs b/app/views/home.ejs index f22196d..d2f82d9 100644 --- a/app/views/home.ejs +++ b/app/views/home.ejs @@ -48,9 +48,15 @@

Friends

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

You don't have any friends yet 🙁

+

Use the search or look in communities to find some

+ <% } %> -

Requests Sent

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

Requests Sent

+ <%- include('_friends', { friends: friends.requestsSent }) %> + <% } %> diff --git a/app/views/mobile/communities/community.ejs b/app/views/mobile/communities/community.ejs new file mode 100644 index 0000000..86e754f --- /dev/null +++ b/app/views/mobile/communities/community.ejs @@ -0,0 +1,20 @@ +
+

+ + #<%= community.name %> + +

+ +
+
+
+
+
+ <% posts.map(post => { %> + " class="columns community-topic-link"> +
+ <%= topicTitle(post.value) %> +
+
💬 <%= post.value.replies.length %> replies
+
+ <% }) %> +
\ No newline at end of file diff --git a/app/views/mobile/communities/list.ejs b/app/views/mobile/communities/list.ejs new file mode 100644 index 0000000..fc6c4e0 --- /dev/null +++ b/app/views/mobile/communities/list.ejs @@ -0,0 +1,11 @@ +
+

Communities

+ +
+ <% communities.map(community => { %> + + #<%= community %> + + <% }) %> +
+
\ No newline at end of file diff --git a/app/views/mobile/friends.ejs b/app/views/mobile/friends.ejs index 3227acc..a2f89d5 100644 --- a/app/views/mobile/friends.ejs +++ b/app/views/mobile/friends.ejs @@ -8,7 +8,13 @@

Friends

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

You don't have any friends yet 🙁

+

Use the search or look in communities to find some

+ <% } %> -

Requests Sent

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

Requests Sent

+ <%- include('_friends', { friends: friends.requestsSent }) %> + <% } %> \ No newline at end of file diff --git a/app/views/mobile/secrets.ejs b/app/views/mobile/secrets.ejs index 6513ab2..3785654 100644 --- a/app/views/mobile/secrets.ejs +++ b/app/views/mobile/secrets.ejs @@ -1,6 +1,9 @@ -
-
0 ? "hidden" : "" %> style="margin: 25px 0 20px 0; font-size: 14px;"> - 👻 You don't have any secret messages yet +
"> +
0 ? "hidden" : "" %> style="margin: 25px 0 20px 0;"> +
+
🤫
+
You don't have any secret messages yet
+
<% secretMessages.map(chat => { %> diff --git a/app/views/mobile/secrets/_compose_multiple.ejs b/app/views/mobile/secrets/_compose_multiple.ejs index a508ba4..4e0f0d8 100644 --- a/app/views/mobile/secrets/_compose_multiple.ejs +++ b/app/views/mobile/secrets/_compose_multiple.ejs @@ -1,5 +1,5 @@
- @@ -22,8 +22,9 @@
-
diff --git a/app/views/secrets/_compose_multiple.ejs b/app/views/secrets/_compose_multiple.ejs index 0039ec0..e1686a9 100644 --- a/app/views/secrets/_compose_multiple.ejs +++ b/app/views/secrets/_compose_multiple.ejs @@ -16,8 +16,9 @@