1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-12-04 03:22:43 +03:00

Use MatrixClientPeg::safeGet in src/{stores,hooks,components/structures}/* (#10988)

This commit is contained in:
Michael Telatynski
2023-06-15 15:11:49 +01:00
committed by GitHub
parent 707fd9ccf0
commit dd46db4817
34 changed files with 139 additions and 130 deletions

View File

@@ -291,7 +291,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
readMarkerEventId: this.initialReadMarkerId,
backPaginating: false,
forwardPaginating: false,
clientSyncState: MatrixClientPeg.get().getSyncState(),
clientSyncState: MatrixClientPeg.safeGet().getSyncState(),
isTwelveHour: SettingsStore.getValue("showTwelveHourTimestamps"),
alwaysShowTimestamps: SettingsStore.getValue("alwaysShowTimestamps"),
readMarkerInViewThresholdMs: SettingsStore.getValue("readMarkerInViewThresholdMs"),
@@ -299,7 +299,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
};
this.dispatcherRef = dis.register(this.onAction);
const cli = MatrixClientPeg.get();
const cli = MatrixClientPeg.safeGet();
cli.on(RoomEvent.Timeline, this.onRoomTimeline);
cli.on(RoomEvent.TimelineReset, this.onRoomTimelineReset);
cli.on(RoomEvent.Redaction, this.onRoomRedaction);
@@ -788,7 +788,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
// read-marker when a remote echo of an event we have just sent takes
// more than the timeout on userActiveRecently.
//
const myUserId = MatrixClientPeg.get().credentials.userId;
const myUserId = MatrixClientPeg.safeGet().credentials.userId;
callRMUpdated = false;
if (ev.getSender() !== myUserId && !UserActivity.sharedInstance().userActiveRecently()) {
updatedState.readMarkerVisible = true;
@@ -881,7 +881,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
if (!this.hasTimelineSetFor(member.roomId)) return;
// ignore events for other users
if (member.userId != MatrixClientPeg.get().credentials?.userId) return;
if (member.userId != MatrixClientPeg.safeGet().credentials?.userId) return;
// We could skip an update if the power level change didn't cross the
// threshold for `VISIBILITY_CHANGE_TYPE`.
@@ -1276,7 +1276,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
}
// now think about advancing it
const myUserId = MatrixClientPeg.get().credentials.userId;
const myUserId = MatrixClientPeg.safeGet().credentials.userId;
for (i++; i < events.length; i++) {
const ev = events[i];
if (ev.getSender() !== myUserId) {
@@ -1557,7 +1557,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
* @param {boolean?} scrollIntoView whether to scroll the event into view.
*/
private loadTimeline(eventId?: string, pixelOffset?: number, offsetBase?: number, scrollIntoView = true): void {
const cli = MatrixClientPeg.get();
const cli = MatrixClientPeg.safeGet();
this.timelineWindow = new TimelineWindow(cli, this.props.timelineSet, { windowLimit: this.props.timelineCap });
this.overlayTimelineWindow = this.props.overlayTimelineSet
? new TimelineWindow(cli, this.props.overlayTimelineSet, { windowLimit: this.props.timelineCap })
@@ -1748,7 +1748,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
arrayFastClone(events)
.reverse()
.forEach((event) => {
const client = MatrixClientPeg.get();
const client = MatrixClientPeg.safeGet();
client.decryptEventIfNeeded(event);
});
@@ -1796,7 +1796,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
* such events were found, then it returns 0.
*/
private checkForPreJoinUISI(events: MatrixEvent[]): number {
const cli = MatrixClientPeg.get();
const cli = MatrixClientPeg.safeGet();
const room = this.props.timelineSet.room;
const isThreadTimeline = [TimelineRenderingType.Thread, TimelineRenderingType.ThreadsList].includes(
@@ -1921,7 +1921,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
const messagePanelNode = ReactDOM.findDOMNode(messagePanel) as Element;
if (!messagePanelNode) return null; // sometimes this happens for fresh rooms/post-sync
const wrapperRect = messagePanelNode.getBoundingClientRect();
const myUserId = MatrixClientPeg.get().credentials.userId;
const myUserId = MatrixClientPeg.safeGet().credentials.userId;
const isNodeInView = (node?: HTMLElement): boolean => {
if (node) {
@@ -2121,7 +2121,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
canBackPaginate={this.state.canBackPaginate && this.state.firstVisibleEventIndex === 0}
showUrlPreview={this.props.showUrlPreview}
showReadReceipts={this.props.showReadReceipts}
ourUserId={MatrixClientPeg.get().getSafeUserId()}
ourUserId={MatrixClientPeg.safeGet().getSafeUserId()}
stickyBottom={stickyBottom}
onScroll={this.onMessageListScroll}
onFillRequest={this.onMessageListFillRequest}