Fix endless scrolling when scrolling through chat history #1273
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue in v1.5.10 where scrolling up through the chat history would cause it to endlessly load older messages.
The problem happens because, I'm guessing, in electron 11 an element that has flex-flow as column-reverse will also reverse the scrollTop value - meaning it starts at 0 when not scrolled and then it goes down into the negatives as you start scrolling.
This change also means that we no longer have to calculate the position of the top message when adding older messages to the view, since it's based on the bottom of the view. So I changed this around to only save the scrollTop and then set that back when we added the older messages. For whatever reason the scroll position still changes when adding items, so we do have to save it. I also had to set the saved scroll top position at a later time as just setting it in adjustMainPos meant that it would be overridden.