add following

This commit is contained in:
biglyderv 2024-09-22 19:11:15 -04:00
parent ba522e044a
commit 20dbce62cb
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954
3 changed files with 20 additions and 14 deletions

View file

@ -26,15 +26,14 @@ let main = new Route([auth], async function (req, res, input) {
username, username,
target target
]); ]);
res.send({'success': true, 'message': 'User unfollowed'});
} else { } else {
await db.run('INSERT INTO follow (username,target) VALUES (?,?)', [ await db.run('INSERT INTO follow (username,target) VALUES (?,?)', [
username, username,
target target
]); ]);
res.send({'success': true, 'message': 'User followed'});
} }
res.send({ redir: `?` });
}); });
export default main; export default main;

View file

@ -16,7 +16,7 @@ async function formClick(ev) {
let json = await fetched.json(); let json = await fetched.json();
document.querySelector('.form-message').textContent = json.message; target.querySelector('.form-message').textContent = json.message;
if (json.redirect) { if (json.redirect) {
setTimeout(function () { setTimeout(function () {

View file

@ -1,20 +1,27 @@
<%- include('header.ejs') -%> <%- include('header.ejs') -%>
<div class='area'> <form enctype='multipart/form-data' method='POST' action='/api/form/follow'>
<h1>User</h1> <h1>User</h1>
<form class='user' enctype='multipart/form-data' method='POST' action='/api/form/follow'> <div class='form-message'></div>
<div class='user'>
<p> <p>
<b>@<%= id %></b> <b>@<%= id %></b>
</p> </p>
<p> <details>
<%= following.length %> following <summary> <%= following.length %> following</summary>
</p> <% for (let user of following) { %>
<p> <a href='/client/user?id=<%= user.target %>'><%= user.target %></a>
<%= followers.length %> followers <%} %>
</p> </details>
<details>
<summary> <%= followers.length %> followers</summary>
<% for (let user of followers) { %>
<a href='/client/user?id=<%= user.username %>'><%= user.username %></a>
<%} %>
</details>
<input name='target' hidden value="<%= id %>"> <input name='target' hidden value="<%= id %>">
<input type='submit' value="Follow"> <input type='submit' value="Follow">
</form> </div>
</div> </form>
<div class='area'> <div class='area'>
<h1>Uploaded Videos</h1> <h1>Uploaded Videos</h1>
<div class=' videos'> <div class=' videos'>