From 20dbce62cb60757d1ed362d5065dbd7df8c2d067 Mon Sep 17 00:00:00 2001 From: onezDerv Date: Sun, 22 Sep 2024 19:11:15 -0400 Subject: [PATCH] add following --- form/follow.js | 5 ++--- static/main.js | 2 +- views/user.ejs | 27 +++++++++++++++++---------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/form/follow.js b/form/follow.js index 3ce8943..cc5a782 100644 --- a/form/follow.js +++ b/form/follow.js @@ -26,15 +26,14 @@ let main = new Route([auth], async function (req, res, input) { username, target ]); + res.send({'success': true, 'message': 'User unfollowed'}); } else { await db.run('INSERT INTO follow (username,target) VALUES (?,?)', [ username, target ]); + res.send({'success': true, 'message': 'User followed'}); } - - - res.send({ redir: `?` }); }); export default main; \ No newline at end of file diff --git a/static/main.js b/static/main.js index ca61fa2..32a7ee5 100644 --- a/static/main.js +++ b/static/main.js @@ -16,7 +16,7 @@ async function formClick(ev) { let json = await fetched.json(); - document.querySelector('.form-message').textContent = json.message; + target.querySelector('.form-message').textContent = json.message; if (json.redirect) { setTimeout(function () { diff --git a/views/user.ejs b/views/user.ejs index a2e2a73..5b58753 100644 --- a/views/user.ejs +++ b/views/user.ejs @@ -1,20 +1,27 @@ <%- include('header.ejs') -%> -
+

User

- +
+

@<%= id %>

-

- <%= following.length %> following -

-

- <%= followers.length %> followers -

+
+ <%= following.length %> following + <% for (let user of following) { %> + <%= user.target %> + <%} %> +
+
+ <%= followers.length %> followers + <% for (let user of followers) { %> + <%= user.username %> + <%} %> +
- -
+
+

Uploaded Videos