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

Commit 0d07613

Browse files
committed
Fix: Remove onUserScroll handler and merge it with onScroll
1 parent 28eb5c2 commit 0d07613

File tree

7 files changed

+29
-55
lines changed

7 files changed

+29
-55
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { createRef, KeyboardEvent, ReactNode, SyntheticEvent, TransitionEvent } from 'react';
17+
import React, { createRef, KeyboardEvent, ReactNode, TransitionEvent } from 'react';
1818
import ReactDOM from 'react-dom';
1919
import classNames from 'classnames';
2020
import { Room } from 'matrix-js-sdk/src/models/room';
@@ -170,9 +170,6 @@ interface IProps {
170170
// callback which is called when the panel is scrolled.
171171
onScroll?(event: Event): void;
172172

173-
// callback which is called when the user interacts with the room timeline
174-
onUserScroll(event: SyntheticEvent): void;
175-
176173
// callback which is called when more content is needed.
177174
onFillRequest?(backwards: boolean): Promise<boolean>;
178175

@@ -1030,7 +1027,6 @@ export default class MessagePanel extends React.Component<IProps, IState> {
10301027
ref={this.scrollPanel}
10311028
className={classes}
10321029
onScroll={this.props.onScroll}
1033-
onUserScroll={this.props.onUserScroll}
10341030
onFillRequest={this.props.onFillRequest}
10351031
onUnfillRequest={this.props.onUnfillRequest}
10361032
style={style}

src/components/structures/RightPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ export default class RightPanel extends React.Component<IProps, IState> {
231231
mxEvent={cardState.threadHeadEvent}
232232
initialEvent={cardState.initialEvent}
233233
isInitialEventHighlighted={cardState.isInitialEventHighlighted}
234+
initialEventScrollIntoView={cardState.initialEventScrollIntoView}
234235
permalinkCreator={this.props.permalinkCreator}
235236
e2eStatus={this.props.e2eStatus}
236237
/>;

src/components/structures/RoomView.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -768,21 +768,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
768768
}
769769
}
770770

771-
private onUserScroll = () => {
772-
if (this.state.initialEventId && this.state.initialEventScrollIntoView) {
773-
debuglog("Removing scroll_into_view flag from initial event");
774-
dis.dispatch<ViewRoomPayload>({
775-
action: Action.ViewRoom,
776-
room_id: this.state.room.roomId,
777-
event_id: this.state.initialEventId,
778-
highlighted: this.state.isInitialEventHighlighted,
779-
scroll_into_view: false,
780-
replyingToEvent: this.state.replyToEvent,
781-
metricsTrigger: undefined, // room doesn't change
782-
});
783-
}
784-
};
785-
786771
private onRightPanelStoreUpdate = () => {
787772
this.setState({
788773
showRightPanel: RightPanelStore.instance.isOpenForRoom(this.state.roomId),
@@ -1311,6 +1296,19 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
13111296
});
13121297
}
13131298
this.updateTopUnreadMessagesBar();
1299+
1300+
if (this.state.initialEventId && this.state.initialEventScrollIntoView) {
1301+
debuglog("Removing scroll_into_view flag from initial event");
1302+
dis.dispatch<ViewRoomPayload>({
1303+
action: Action.ViewRoom,
1304+
room_id: this.state.room.roomId,
1305+
event_id: this.state.initialEventId,
1306+
highlighted: this.state.isInitialEventHighlighted,
1307+
scroll_into_view: false,
1308+
replyingToEvent: this.state.replyToEvent,
1309+
metricsTrigger: undefined, // room doesn't change
1310+
});
1311+
}
13141312
};
13151313

13161314
private injectSticker(url: string, info: object, text: string, threadId: string | null) {
@@ -2066,7 +2064,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
20662064
eventScrollIntoView={this.state.initialEventScrollIntoView}
20672065
eventPixelOffset={this.state.initialEventPixelOffset}
20682066
onScroll={this.onMessageListScroll}
2069-
onUserScroll={this.onUserScroll}
20702067
onReadMarkerUpdated={this.updateTopUnreadMessagesBar}
20712068
showUrlPreview={this.state.showUrlPreview}
20722069
className={this.messagePanelClassNames}

src/components/structures/ScrollPanel.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { createRef, CSSProperties, ReactNode, SyntheticEvent, KeyboardEvent } from "react";
17+
import React, { createRef, CSSProperties, ReactNode, KeyboardEvent } from "react";
1818
import { logger } from "matrix-js-sdk/src/logger";
1919

2020
import Timer from '../../utils/Timer';
@@ -109,10 +109,6 @@ interface IProps {
109109
/* onScroll: a callback which is called whenever any scroll happens.
110110
*/
111111
onScroll?(event: Event): void;
112-
113-
/* onUserScroll: callback which is called when the user interacts with the room timeline
114-
*/
115-
onUserScroll?(event: SyntheticEvent): void;
116112
}
117113

118114
/* This component implements an intelligent scrolling list.
@@ -593,29 +589,21 @@ export default class ScrollPanel extends React.Component<IProps> {
593589
* @param {object} ev the keyboard event
594590
*/
595591
public handleScrollKey = (ev: KeyboardEvent) => {
596-
let isScrolling = false;
597592
const roomAction = getKeyBindingsManager().getRoomAction(ev);
598593
switch (roomAction) {
599594
case KeyBindingAction.ScrollUp:
600595
this.scrollRelative(-1);
601-
isScrolling = true;
602596
break;
603597
case KeyBindingAction.ScrollDown:
604598
this.scrollRelative(1);
605-
isScrolling = true;
606599
break;
607600
case KeyBindingAction.JumpToFirstMessage:
608601
this.scrollToTop();
609-
isScrolling = true;
610602
break;
611603
case KeyBindingAction.JumpToLatestMessage:
612604
this.scrollToBottom();
613-
isScrolling = true;
614605
break;
615606
}
616-
if (isScrolling && this.props.onUserScroll) {
617-
this.props.onUserScroll(ev);
618-
}
619607
};
620608

621609
/* Scroll the panel to bring the DOM node with the scroll token
@@ -965,7 +953,6 @@ export default class ScrollPanel extends React.Component<IProps> {
965953
<AutoHideScrollbar
966954
wrappedRef={this.collectScroll}
967955
onScroll={this.onScroll}
968-
onWheel={this.props.onUserScroll}
969956
className={`mx_ScrollPanel ${this.props.className}`}
970957
style={this.props.style}
971958
>

src/components/structures/ThreadView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
375375
eventId={this.props.initialEvent?.getId()}
376376
highlightedEventId={highlightedEventId}
377377
eventScrollIntoView={this.props.initialEventScrollIntoView}
378-
onUserScroll={this.resetJumpToEvent}
378+
onScroll={this.resetJumpToEvent}
379379
onPaginationRequest={this.onPaginationRequest}
380380
/>
381381
</div> }

src/components/structures/TimelinePanel.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { createRef, ReactNode, SyntheticEvent } from 'react';
17+
import React, { createRef, ReactNode } from 'react';
1818
import ReactDOM from "react-dom";
1919
import { NotificationCountType, Room, RoomEvent } from "matrix-js-sdk/src/models/room";
2020
import { MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event";
@@ -127,9 +127,6 @@ interface IProps {
127127
// callback which is called when the panel is scrolled.
128128
onScroll?(event: Event): void;
129129

130-
// callback which is called when the user interacts with the room timeline
131-
onUserScroll?(event: SyntheticEvent): void;
132-
133130
// callback which is called when the read-up-to mark is updated.
134131
onReadMarkerUpdated?(): void;
135132

@@ -1664,7 +1661,6 @@ class TimelinePanel extends React.Component<IProps, IState> {
16641661
ourUserId={MatrixClientPeg.get().credentials.userId}
16651662
stickyBottom={stickyBottom}
16661663
onScroll={this.onMessageListScroll}
1667-
onUserScroll={this.props.onUserScroll}
16681664
onFillRequest={this.onMessageListFillRequest}
16691665
onUnfillRequest={this.onMessageListUnfillRequest}
16701666
isTwelveHour={this.context?.showTwelveHourTimestamps ?? this.state.isTwelveHour}

src/components/views/right_panel/TimelineCard.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,6 @@ export default class TimelineCard extends React.Component<IProps, IState> {
146146
}
147147
};
148148

149-
private onUserScroll = (): void => {
150-
if (this.state.initialEventId && this.state.isInitialEventHighlighted) {
151-
dis.dispatch<ViewRoomPayload>({
152-
action: Action.ViewRoom,
153-
room_id: this.props.room.roomId,
154-
event_id: this.state.initialEventId,
155-
highlighted: false,
156-
replyingToEvent: this.state.replyToEvent,
157-
metricsTrigger: undefined, // room doesn't change
158-
});
159-
}
160-
};
161-
162149
private onScroll = (): void => {
163150
const timelinePanel = this.timelinePanel.current;
164151
if (!timelinePanel) return;
@@ -171,6 +158,17 @@ export default class TimelineCard extends React.Component<IProps, IState> {
171158
atEndOfLiveTimeline: false,
172159
});
173160
}
161+
162+
if (this.state.initialEventId && this.state.isInitialEventHighlighted) {
163+
dis.dispatch<ViewRoomPayload>({
164+
action: Action.ViewRoom,
165+
room_id: this.props.room.roomId,
166+
event_id: this.state.initialEventId,
167+
highlighted: false,
168+
replyingToEvent: this.state.replyToEvent,
169+
metricsTrigger: undefined, // room doesn't change
170+
});
171+
}
174172
};
175173

176174
private onMeasurement = (narrow: boolean): void => {
@@ -263,7 +261,6 @@ export default class TimelineCard extends React.Component<IProps, IState> {
263261
resizeNotifier={this.props.resizeNotifier}
264262
highlightedEventId={highlightedEventId}
265263
onScroll={this.onScroll}
266-
onUserScroll={this.onUserScroll}
267264
/>
268265
</div>
269266

0 commit comments

Comments
 (0)