Closed
Description
Description
Steps to reproduce:
- Create a repo
- Create a PR with a lot of changed files (in my case 193)
- Start reviewing the PR, marking each reviewed file as "viewed" with the checkbox
- Once the first 100 files are marked as viewed, click the "load more" button at the end of the page to load the rest of the files
- Mark the 101st file as viewed
Expected behavior:
101 files are marked as viewed
Actual behavior:
99 files are marked as viewed
The very first file is un-marked as viewed when marking the 101st file as viewed. When I mark it as viewed again, 100 files are marked as viewed again. When I then try to mark another of the newly loaded files as viewed, it unmarks the first file again, resulting in 99 files are marked as viewed.
Gitea Version
1.17.0
Can you reproduce the bug on the Gitea demo site?
Probably (on the go right now, will try to reproduce it later)
How are you running Gitea?
Official docker image.
Database
MySQL
Activity
delvh commentedon Aug 5, 2022
Hmm.
I have absolutely no idea what could cause this.
I'm fairly certain I've tested the behavior on #19007, and there it worked correctly.
To be fair, I only tested by marking some and not all files as viewed before loading more files dynamically, but still?
I don't see anything in the code (I wrote) (
web_src/js/features/pull-view-file.js
) that would cause this, unlessthis.checked
(wherethis
is a checkbox) was inverted by default for some reason?delvh commentedon Aug 5, 2022
Yep, just confirmed it on try.gitea.io (https://try.gitea.io/delvh/kanban-test/pulls/25/files).
I had even stranger behavior: For me, the counter was reset to
0
(when loading more files), meaning that when I clicked on the101
st checkbox, the1
st checkbox was acted upon, and as that was already selected, it was de-selected, thus bringing the counter down to-1
.So, to me, the first issue appears to be an index issue where if
x
files are loaded initially, all subsequent ones useindex - x
(orindex % x
?) for the viewed checkbox JS. However, I still have no idea why this could be the case, and why I didn't notice it originally.The second issue is that the counter was reset to
0
, which it shouldn't.Prevent invalid behavior for file reviewing when loading more files (#…
Prevent invalid behavior for file reviewing when loading more files (g…
Prevent invalid behavior for file reviewing when loading more files (#…