Skip to content
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

Feat: Show update progress in winbar #432

Conversation

jakubbortlik
Copy link
Collaborator

Hi @harrisoncramer, this is an attempt to implement #409.

With this PR, the winbar shows the time since the last update of the discussion data and it shows a simple animation when the data is being reloaded.

There are some shortcomings that would require some more work to solve:

  1. The winbar has become quite crammed when using position left or right for the discussion tree, so that the "Inline Comments" section can easily move outside of the window. To fix this, we'd have to add some more elaborate winbar string calculation that would take the window width and the components into account. This can be done in a separate follow-up PR, I believe
  2. The drafts data are loaded significantly faster* than regular discussion data, this results in a short inconsistency in the winbar when manipulating the drafts - the number of drafts is updated in the winbar faster than it is rendered in the discussion tree (and before the update spinner finishes), because rebuilding the discussion tree is postponed until after all discussion data are reloaded. I believe this could be fixed by changing the order in which the data are reloaded. Consider the following pseudocode.

The current order:

draft_notes.rebuild_view = function(unlinked, all)
    discussions.rebuild_view(unlinked, all)
end

would change to:

discussions.rebuild_view = function(unlinked, all)
    draft_notes.rebuild_view(unlinked, all)
end

I haven't tried this, but I believe it would make the discrepancy between the winbar and the discussion tree much smaller. I'm going to give this a try.

* I've made some simple measurements, and it looks like even in a very small testing repo with a very small MR (13 items in the overview) it takes about 2 seconds for the discussion tree to reload. The drafts are reloaded in fractions of a second. I'm wondering if this is just how Gitlab works, or if there may be some way to make the go server do this faster.

jakubbortlik added a commit to jakubbortlik/gitlab.nvim that referenced this pull request Dec 5, 2024
The discussion tree takes some time to rebuild and for a short time there is a discrepancy between
the indicated sort method and the actual sorting. This will be less of a problem if harrisoncramer#432 is merged
so the user will see that the discussion tree is being refreshed.
jakubbortlik added a commit to jakubbortlik/gitlab.nvim that referenced this pull request Dec 5, 2024
The discussion tree takes some time to rebuild and for a short time there is a discrepancy between
the indicated sort method and the actual sorting. This will be less of a problem if harrisoncramer#432 is merged
so the user will see that the discussion tree is being refreshed.
Since the winbar is now updated automatically, it's not necessary to update it explicitly. For some
reason, however, removing the `update_winbar` call in `switch_view_type()`
(`gitlab/actions/discussions/winbar.lua`) causes a minor screen flicker, so I've kept that one in.
fix: unify with Gitlab.com
Setting last_updated in the `discussions.refresh_dagnostics` caused incorrect last_updated time when
switching tabs (due to `discussions.refresh_dagnostics` being included the callback for file changes
with the DiffviewDiffBufWinEnter User autocommand).
@jakubbortlik jakubbortlik force-pushed the feat-show-update-progress-in-winbar branch from ee597cf to bd3a92b Compare December 6, 2024 14:11
@harrisoncramer harrisoncramer merged commit b2d64fa into harrisoncramer:develop Dec 8, 2024
6 checks passed
@jakubbortlik jakubbortlik deleted the feat-show-update-progress-in-winbar branch December 9, 2024 07:43
harrisoncramer added a commit that referenced this pull request Dec 11, 2024
* Feat: Enable sorting discussions by original comment (#422)
* Feat: Improve popup UX (#426)
* Feat: Automatically update MR summary details (#427)
* Feat: Show update progress in winbar (#432)
* Feat: Abbreviate winbar (#439)
* Fix: Note Creation Bug (#441)
* Fix: Checking whether comment can be created (#434)
* Fix: Syntax in discussion tree (#433)
* fix: improve indication of resolved threads and drafts (#442)
* Docs: Various minor improvements (#445)

---------

Co-authored-by: Jakub F. Bortlík <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants