Skip to content

Partially refresh notifications list #35010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 10, 2025

Conversation

anbraten
Copy link
Contributor

@anbraten anbraten commented Jul 9, 2025

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
@github-actions github-actions bot added modifies/templates This PR modifies the template files modifies/frontend labels Jul 9, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jul 9, 2025

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
Copy link
Contributor Author

anbraten commented Jul 9, 2025

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
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
Copy link
Member

silverwind commented Jul 9, 2025

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.

@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jul 9, 2025
@anbraten
Copy link
Contributor Author

anbraten commented Jul 9, 2025

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
@github-actions github-actions bot removed the modifies/go Pull requests that update Go code label Jul 9, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/frontend labels Jul 9, 2025
{{if eq .Status 1}}
{{ctx.Locale.Tr "notification.no_unread"}}
<div id="notification_table">
{{range $one := .Notifications}}
Copy link
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
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

pager := context.NewPagination(int(total), perPage, page, 5)
if pager.Paginater.Current() < page {
ctx.Redirect(fmt.Sprintf("%s/notifications?q=%s&page=%d", setting.AppSubURL, url.QueryEscape(ctx.FormString("q")), pager.Paginater.Current()))
return
}

statuses := []activities_model.NotificationStatus{status, activities_model.NotificationStatusPinned}
statuses := []activities_model.NotificationStatus{queryStatus, activities_model.NotificationStatusPinned}
Copy link
Contributor Author

@anbraten anbraten Jul 9, 2025

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
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?

@wxiaoguang
Copy link
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants