Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3a245a0

Browse files
Fix jump to bottom button being always displayed in non-overflowing timelines (#8460)
1 parent d294dad commit 3a245a0

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

src/components/structures/RoomView.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ export interface IRoomState {
179179
// this is true if we are fully scrolled-down, and are looking at
180180
// the end of the live timeline. It has the effect of hiding the
181181
// 'scroll to bottom' knob, among a couple of other things.
182-
atEndOfLiveTimeline: boolean;
183-
// used by componentDidUpdate to avoid unnecessary checks
184-
atEndOfLiveTimelineInit: boolean;
182+
atEndOfLiveTimeline?: boolean;
185183
showTopUnreadMessagesBar: boolean;
186184
statusBarVisible: boolean;
187185
// We load this later by asking the js-sdk to suggest a version for us.
@@ -257,8 +255,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
257255
isPeeking: false,
258256
showRightPanel: false,
259257
joining: false,
260-
atEndOfLiveTimeline: true,
261-
atEndOfLiveTimelineInit: false,
262258
showTopUnreadMessagesBar: false,
263259
statusBarVisible: false,
264260
canReact: false,
@@ -692,9 +688,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
692688
// in render() prevents the ref from being set on first mount, so we try and
693689
// catch the messagePanel when it does mount. Because we only want the ref once,
694690
// we use a boolean flag to avoid duplicate work.
695-
if (this.messagePanel && !this.state.atEndOfLiveTimelineInit) {
691+
if (this.messagePanel && this.state.atEndOfLiveTimeline === undefined) {
696692
this.setState({
697-
atEndOfLiveTimelineInit: true,
698693
atEndOfLiveTimeline: this.messagePanel.isAtEndOfLiveTimeline(),
699694
});
700695
}
@@ -2102,7 +2097,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
21022097
}
21032098
let jumpToBottom;
21042099
// Do not show JumpToBottomButton if we have search results showing, it makes no sense
2105-
if (!this.state.atEndOfLiveTimeline && !this.state.searchResults) {
2100+
if (this.state.atEndOfLiveTimeline === false && !this.state.searchResults) {
21062101
jumpToBottom = (<JumpToBottomButton
21072102
highlight={this.state.room.getUnreadNotificationCount(NotificationCountType.Highlight) > 0}
21082103
numUnreadMessages={this.state.numUnreadMessages}

src/components/structures/TimelinePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
10431043
/* return true if the content is fully scrolled down and we are
10441044
* at the end of the live timeline.
10451045
*/
1046-
public isAtEndOfLiveTimeline = (): boolean => {
1046+
public isAtEndOfLiveTimeline = (): boolean | undefined => {
10471047
return this.messagePanel.current?.isAtBottom()
10481048
&& this.timelineWindow
10491049
&& !this.timelineWindow.canPaginate(EventTimeline.FORWARDS);

src/contexts/RoomContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ const RoomContext = createContext<IRoomState>({
4141
isPeeking: false,
4242
showRightPanel: true,
4343
joining: false,
44-
atEndOfLiveTimeline: true,
45-
atEndOfLiveTimelineInit: false,
4644
showTopUnreadMessagesBar: false,
4745
statusBarVisible: false,
4846
canReact: false,

test/components/views/rooms/MessageComposerButtons-test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ function createRoomState(room: Room, narrow: boolean): IRoomState {
216216
showRightPanel: true,
217217
joining: false,
218218
atEndOfLiveTimeline: true,
219-
atEndOfLiveTimelineInit: false,
220219
showTopUnreadMessagesBar: false,
221220
statusBarVisible: false,
222221
canReact: false,

0 commit comments

Comments
 (0)