Skip to content

Partially refresh notifications list#35010

Merged
wxiaoguang merged 12 commits into
go-gitea:mainfrom
anbraten:htmx-notifications
Jul 10, 2025
Merged

Partially refresh notifications list#35010
wxiaoguang merged 12 commits into
go-gitea:mainfrom
anbraten:htmx-notifications

Conversation

@anbraten

@anbraten anbraten commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

This PR prevents full reloads for the notifications list when changing a notifications status (read, unread, pinned).

Currently marking several notifications as read is pretty slow for me as you have to wait for the full page reload to before marking the next entry as read (especially on larger instances or when having a slower connection to them).

as discussed in #33465

Before:

Notifications.-.Gitea_.Git.with.a.cup.of.tea.-.Google.Chrome.2025-07-09.14-29-25.mp4

After:

Notifications.-.Gitea_.Git.with.a.cup.of.tea.-.Google.Chrome.2025-07-09.14-31-12.mp4

Todos / open questions

  • Should none js systems be supported? Currently added type button so the forms are unused

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 9, 2025
@wxiaoguang

wxiaoguang commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Could you elaborate what's the goal of this PR and what problem it would fix?

IMO we could:

  • completely drop the "notification page auto-reload by the Server-sent event" support.
  • make the notification page reload (full refresh) when navigating between pages, just like issues/PRs and other list pages.

Then everything could be simplified, and user experience is still good.

@anbraten

anbraten commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

make the notification page reload (full refresh) when navigating between pages, just like issues/PRs and other list pages.

The goal of the PR is to improve UX when checking notifications. I am using the notifications as my entrypoint for most interactions with Gitea and as something like a ToDo list. Currently marking several notifications as read is pretty slow for me as you have to wait for the full page reload to check the next entry (especially on larger instances or when having a slower connection to them).

@wxiaoguang

Copy link
Copy Markdown
Contributor

Currently marking several notifications as read is pretty slow for me as you have to wait for the full page reload to check the next entry (especially on larger instances or when having a slower connection to them).

Then I think we need to add some checkboxes like GitHub, but not "partially refresh". "partially refresh" won't make noticeable speed-up.

image

@silverwind

silverwind commented Jul 9, 2025

Copy link
Copy Markdown
Member

I'm definitely in favor of dropping the (buggy) SSE code. Websocket is the final goal, but I can accept a polling-based approach as an interim solution which should be much easier to implement.

@anbraten

anbraten commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

I've fixed the htmx code now, the status post was missing the noredirect parameter.

"partially refresh" won't make noticeable speed-up.

I would say it does. Loading the complete page and assets again is quite a bit slower and lets the browser flicker, so staying at the same position and clicking on one notification after another is no fun. Added a recording to the description that shows how it works using a fast but not instant 4g connection.

@anbraten anbraten changed the title feat: partially refresh notifications list Partially refresh notifications list Jul 9, 2025
Comment thread routers/web/user/notification.go Outdated
Comment thread templates/user/notification/notification_div.tmpl Outdated
Comment thread web_src/js/features/notification.ts Outdated
{{if eq .Status 1}}
{{ctx.Locale.Tr "notification.no_unread"}}
<div id="notification_table">
{{range $one := .Notifications}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keeping notification instead of one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using $notification in the code below will make the line unnecessarily long .... we will get:

{{$notification.Repository.FullName}} {{if $notification.Issue}}<span class="text light-3">#{{$notification.Issue.Index}}</span>{{end}}

I think $one.ID is clear enough

Comment thread web_src/css/user.css
Comment thread routers/web/user/notification.go
}

statuses := []activities_model.NotificationStatus{status, activities_model.NotificationStatusPinned}
statuses := []activities_model.NotificationStatus{queryStatus, activities_model.NotificationStatusPinned}

@anbraten anbraten Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pinned status would still appear in both lists which is somehow strange IMO. No idea what the best way to improve would be as I am in general not 100% sure how ppl use this. Would it make sense to put pinned entries to the top?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the problem to the future?

Comment thread web_src/js/features/notification.ts Outdated
Comment thread web_src/js/features/notification.ts
@wxiaoguang

Copy link
Copy Markdown
Contributor

Done from my side, much more changes than I thought .....

@wxiaoguang wxiaoguang marked this pull request as ready for review July 9, 2025 15:44
@wxiaoguang wxiaoguang added the type/enhancement An improvement of existing functionality label Jul 9, 2025
@wxiaoguang wxiaoguang added this to the 1.25.0 milestone Jul 9, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 9, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 10, 2025
@wxiaoguang wxiaoguang enabled auto-merge (squash) July 10, 2025 03:55
@wxiaoguang wxiaoguang merged commit ea809a5 into go-gitea:main Jul 10, 2025
26 checks passed
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 10, 2025
* giteaofficial/main:
  Fix ListWorkflowRuns OpenAPI response model. (go-gitea#35026)
  Partially refresh notifications list (go-gitea#35010)
@wxiaoguang wxiaoguang mentioned this pull request Jul 12, 2025
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants