Use reddit-style notifs without context

The notifications schema is already set up for reddit-style
chronological notifications. We simply have to remove the logic that
builds the context and patch up a few places in the frontend that
were expecting full reply trees.

`Comment.header_msg` previously expected the user's own comment to
be top-level in comment replies. Logic is revised to expect the actual
reply.

`files.routes.front.notifications_main` now has reduced query volume
because we aren't expiring the session when marking notifications read.
This also allows us to remove the unused `comms` variable, which is a
makeshift "pattern" of storing duplicate database replies across a
commit so the templates don't requery (thus losing data attached to
the runtime object, like `c.unread` / `c.notif_utc`).

We move the `is_notification_page` flag to the route callers rather
than templates checking `request.path`.

Minor UI style: "Clear all notifications" -> "Mark All Read", since
this was a persistent point of user confusion upstream, with people
expecting their inbox to empty out. Also less margin between notifs
to be consistent with tighter comment display elsewhere and removed
need to separate groups of comments vs single comments.
This commit is contained in:
TLSM 2023-07-12 00:11:24 -04:00 committed by Ben Rog-Wilhelm
parent 695e6b6dbd
commit 6fde14a92c
4 changed files with 19 additions and 46 deletions

View file

@ -359,7 +359,7 @@ class Comment(CreatedBase):
return self.is_message and not self.sentto
@lazy
def header_msg(self, v, is_notification_page:bool, reply_count:int) -> str:
def header_msg(self, v, is_notification_page: bool) -> str:
'''
Returns a message that is in the header for a comment, usually for
display on a notification page.
@ -367,9 +367,9 @@ class Comment(CreatedBase):
if self.post:
post_html:str = f"<a href=\"{self.post.permalink}\">{self.post.realtitle(v)}</a>"
if v:
if v.id == self.author_id and reply_count:
text = f"Comment {'Replies' if reply_count != 1 else 'Reply'}"
elif v.id == self.post.author_id and self.level == 1:
if self.level > 1 and v.id == self.parent_comment.author_id:
text = "Comment Reply"
elif self.level == 1 and v.id == self.post.author_id:
text = "Post Reply"
elif self.parent_submission in v.subscribed_idlist():
text = "Subscribed Thread"