This commit is contained in:
Akif9748 2022-08-11 18:34:35 +03:00
parent 5414271924
commit 7283404184
3 changed files with 6 additions and 3 deletions

View file

@ -8,7 +8,7 @@ app.get("/:id", async (req, res) => {
const message = await MessageModel.get(req.params.id); const message = await MessageModel.get(req.params.id);
if (!message || (message.deleted && req.user && !req.user.admin)) return res.error( 404, "We have not got any message declared as this id."); if (!message || (message.deleted && req.user && !req.user.admin)) return res.error( 404, "We have not got any message declared as this id.");
res.redirect("/threads/" + message.threadID); res.redirect("/threads/" + message.threadID+"?scroll="+req.params.id);
}); });

View file

@ -39,7 +39,7 @@ app.get("/:id", async (req, res) => {
return user?.admin || !message?.deleted ? message : null; return user?.admin || !message?.deleted ? message : null;
})); }));
res.render("thread", { thread, messages, user }) res.render("thread", { thread, messages, user,scroll:req.query.scroll || false });
} else } else
res.error( 404, "We have not got this thread."); res.error( 404, "We have not got this thread.");
}); });

View file

@ -48,10 +48,13 @@
<% }%> <% }%>
</form> </form>
<% if (user){ %> <% if (user){ %>
<script type="module" src="/js/thread.js"></script> <script type="module" src="/js/thread.js"></script>
<% }%> <% }%>
<script>
document.getElementById("message-<%= scroll %>").scrollIntoView();
</script>
<%- include("extra/footer") %> <%- include("extra/footer") %>
</body> </body>