show subscribed threads in inbox even when there's no unreads

This commit is contained in:
Lera Elvoé 2025-06-05 05:37:12 +03:00
parent 2bf5f4faa3
commit cfb676a453
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
2 changed files with 24 additions and 0 deletions

View File

@ -298,6 +298,15 @@ app:get("user_inbox", "/:username/inbox", function(self)
self.new_posts = {}
local subscription = Subscriptions:find({user_id = me.id})
if subscription then
self.all_subscriptions = db.query([[
SELECT threads.title AS thread_title, threads.slug AS thread_slug
FROM
threads
JOIN
subscriptions ON subscriptions.thread_id = threads.id
WHERE
subscriptions.user_id = ?
]], me.id)
local q = [[
WITH thread_metadata AS (
SELECT

View File

@ -2,6 +2,21 @@
<h1 class="thread-title">Inbox</h1>
</div>
<div class="inbox-container">
<% if not all_subscriptions then %>
You have no subscriptions.<br>
<% else %>
Your subscriptions:
<ul>
<% for _, sub in ipairs(all_subscriptions) do %>
<li><a href="<%= url_for("thread", {slug = sub.thread_slug}) %>"><%= sub.thread_title %></a>
<form class="modform" method="post" action="<%= url_for("thread_subscribe", {slug = sub.thread_slug}) %>">
<input type="hidden" name="subscribe" value="unsubscribe">
<input class="warn" type="submit" value="Unsubscribe">
</form>
</li>
<% end %>
</ul>
<% end %>
<% if #new_posts == 0 then %>
You have no unread posts.
<% else %>