Fix jump to bottom button being always displayed in non-overflowing timelines (#8460)

pull/28788/head^2
Šimon Brandner 2022-05-02 03:38:36 +02:00 committed by GitHub
parent d294dad04d
commit 3a245a0cbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 12 deletions

View File

@ -179,9 +179,7 @@ export interface IRoomState {
// this is true if we are fully scrolled-down, and are looking at // this is true if we are fully scrolled-down, and are looking at
// the end of the live timeline. It has the effect of hiding the // the end of the live timeline. It has the effect of hiding the
// 'scroll to bottom' knob, among a couple of other things. // 'scroll to bottom' knob, among a couple of other things.
atEndOfLiveTimeline: boolean; atEndOfLiveTimeline?: boolean;
// used by componentDidUpdate to avoid unnecessary checks
atEndOfLiveTimelineInit: boolean;
showTopUnreadMessagesBar: boolean; showTopUnreadMessagesBar: boolean;
statusBarVisible: boolean; statusBarVisible: boolean;
// We load this later by asking the js-sdk to suggest a version for us. // 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> {
isPeeking: false, isPeeking: false,
showRightPanel: false, showRightPanel: false,
joining: false, joining: false,
atEndOfLiveTimeline: true,
atEndOfLiveTimelineInit: false,
showTopUnreadMessagesBar: false, showTopUnreadMessagesBar: false,
statusBarVisible: false, statusBarVisible: false,
canReact: false, canReact: false,
@ -692,9 +688,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
// in render() prevents the ref from being set on first mount, so we try and // in render() prevents the ref from being set on first mount, so we try and
// catch the messagePanel when it does mount. Because we only want the ref once, // catch the messagePanel when it does mount. Because we only want the ref once,
// we use a boolean flag to avoid duplicate work. // we use a boolean flag to avoid duplicate work.
if (this.messagePanel && !this.state.atEndOfLiveTimelineInit) { if (this.messagePanel && this.state.atEndOfLiveTimeline === undefined) {
this.setState({ this.setState({
atEndOfLiveTimelineInit: true,
atEndOfLiveTimeline: this.messagePanel.isAtEndOfLiveTimeline(), atEndOfLiveTimeline: this.messagePanel.isAtEndOfLiveTimeline(),
}); });
} }
@ -2102,7 +2097,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
} }
let jumpToBottom; let jumpToBottom;
// Do not show JumpToBottomButton if we have search results showing, it makes no sense // Do not show JumpToBottomButton if we have search results showing, it makes no sense
if (!this.state.atEndOfLiveTimeline && !this.state.searchResults) { if (this.state.atEndOfLiveTimeline === false && !this.state.searchResults) {
jumpToBottom = (<JumpToBottomButton jumpToBottom = (<JumpToBottomButton
highlight={this.state.room.getUnreadNotificationCount(NotificationCountType.Highlight) > 0} highlight={this.state.room.getUnreadNotificationCount(NotificationCountType.Highlight) > 0}
numUnreadMessages={this.state.numUnreadMessages} numUnreadMessages={this.state.numUnreadMessages}

View File

@ -1043,7 +1043,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
/* return true if the content is fully scrolled down and we are /* return true if the content is fully scrolled down and we are
* at the end of the live timeline. * at the end of the live timeline.
*/ */
public isAtEndOfLiveTimeline = (): boolean => { public isAtEndOfLiveTimeline = (): boolean | undefined => {
return this.messagePanel.current?.isAtBottom() return this.messagePanel.current?.isAtBottom()
&& this.timelineWindow && this.timelineWindow
&& !this.timelineWindow.canPaginate(EventTimeline.FORWARDS); && !this.timelineWindow.canPaginate(EventTimeline.FORWARDS);

View File

@ -41,8 +41,6 @@ const RoomContext = createContext<IRoomState>({
isPeeking: false, isPeeking: false,
showRightPanel: true, showRightPanel: true,
joining: false, joining: false,
atEndOfLiveTimeline: true,
atEndOfLiveTimelineInit: false,
showTopUnreadMessagesBar: false, showTopUnreadMessagesBar: false,
statusBarVisible: false, statusBarVisible: false,
canReact: false, canReact: false,

View File

@ -216,7 +216,6 @@ function createRoomState(room: Room, narrow: boolean): IRoomState {
showRightPanel: true, showRightPanel: true,
joining: false, joining: false,
atEndOfLiveTimeline: true, atEndOfLiveTimeline: true,
atEndOfLiveTimelineInit: false,
showTopUnreadMessagesBar: false, showTopUnreadMessagesBar: false,
statusBarVisible: false, statusBarVisible: false,
canReact: false, canReact: false,