Conform more of the codebase to strictNullChecks (#11135)
							parent
							
								
									a87362a048
								
							
						
					
					
						commit
						d404e0656a
					
				| 
						 | 
					@ -16,14 +16,20 @@ See the License for the specific language governing permissions and
 | 
				
			||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { IAuthData, IRequestMsisdnTokenResponse, IRequestTokenResponse, MatrixClient } from "matrix-js-sdk/src/matrix";
 | 
					import {
 | 
				
			||||||
 | 
					    IAddThreePidOnlyBody,
 | 
				
			||||||
 | 
					    IAuthData,
 | 
				
			||||||
 | 
					    IRequestMsisdnTokenResponse,
 | 
				
			||||||
 | 
					    IRequestTokenResponse,
 | 
				
			||||||
 | 
					    MatrixClient,
 | 
				
			||||||
 | 
					} from "matrix-js-sdk/src/matrix";
 | 
				
			||||||
import { MatrixError, HTTPError } from "matrix-js-sdk/src/matrix";
 | 
					import { MatrixError, HTTPError } from "matrix-js-sdk/src/matrix";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import Modal from "./Modal";
 | 
					import Modal from "./Modal";
 | 
				
			||||||
import { _t, UserFriendlyError } from "./languageHandler";
 | 
					import { _t, UserFriendlyError } from "./languageHandler";
 | 
				
			||||||
import IdentityAuthClient from "./IdentityAuthClient";
 | 
					import IdentityAuthClient from "./IdentityAuthClient";
 | 
				
			||||||
import { SSOAuthEntry } from "./components/views/auth/InteractiveAuthEntryComponents";
 | 
					import { SSOAuthEntry } from "./components/views/auth/InteractiveAuthEntryComponents";
 | 
				
			||||||
import InteractiveAuthDialog from "./components/views/dialogs/InteractiveAuthDialog";
 | 
					import InteractiveAuthDialog, { InteractiveAuthDialogProps } from "./components/views/dialogs/InteractiveAuthDialog";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getIdServerDomain(matrixClient: MatrixClient): string {
 | 
					function getIdServerDomain(matrixClient: MatrixClient): string {
 | 
				
			||||||
    const idBaseUrl = matrixClient.getIdentityServerUrl(true);
 | 
					    const idBaseUrl = matrixClient.getIdentityServerUrl(true);
 | 
				
			||||||
| 
						 | 
					@ -239,7 +245,7 @@ export default class AddThreepid {
 | 
				
			||||||
                                [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
 | 
					                                [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
 | 
				
			||||||
                                [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
 | 
					                                [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
 | 
				
			||||||
                            },
 | 
					                            },
 | 
				
			||||||
                        });
 | 
					                        } as InteractiveAuthDialogProps<IAddThreePidOnlyBody>);
 | 
				
			||||||
                        return finished;
 | 
					                        return finished;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -270,11 +276,11 @@ export default class AddThreepid {
 | 
				
			||||||
     * @param {{type: string, session?: string}} auth UI auth object
 | 
					     * @param {{type: string, session?: string}} auth UI auth object
 | 
				
			||||||
     * @return {Promise<Object>} Response from /3pid/add call (in current spec, an empty object)
 | 
					     * @return {Promise<Object>} Response from /3pid/add call (in current spec, an empty object)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private makeAddThreepidOnlyRequest = (auth?: { type: string; session?: string }): Promise<{}> => {
 | 
					    private makeAddThreepidOnlyRequest = (auth?: IAddThreePidOnlyBody["auth"] | null): Promise<{}> => {
 | 
				
			||||||
        return this.matrixClient.addThreePidOnly({
 | 
					        return this.matrixClient.addThreePidOnly({
 | 
				
			||||||
            sid: this.sessionId,
 | 
					            sid: this.sessionId,
 | 
				
			||||||
            client_secret: this.clientSecret,
 | 
					            client_secret: this.clientSecret,
 | 
				
			||||||
            auth,
 | 
					            auth: auth ?? undefined,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -360,7 +366,7 @@ export default class AddThreepid {
 | 
				
			||||||
                            [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
 | 
					                            [SSOAuthEntry.LOGIN_TYPE]: dialogAesthetics,
 | 
				
			||||||
                            [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
 | 
					                            [SSOAuthEntry.UNSTABLE_LOGIN_TYPE]: dialogAesthetics,
 | 
				
			||||||
                        },
 | 
					                        },
 | 
				
			||||||
                    });
 | 
					                    } as InteractiveAuthDialogProps<IAddThreePidOnlyBody>);
 | 
				
			||||||
                    return finished;
 | 
					                    return finished;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,7 +90,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
     * during room changes.
 | 
					     * during room changes.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public get isOpen(): boolean {
 | 
					    public get isOpen(): boolean {
 | 
				
			||||||
        return this.byRoom[this.viewedRoomId]?.isOpen ?? false;
 | 
					        return this.byRoom[this.viewedRoomId ?? ""]?.isOpen ?? false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public isOpenForRoom(roomId: string): boolean {
 | 
					    public isOpenForRoom(roomId: string): boolean {
 | 
				
			||||||
| 
						 | 
					@ -98,7 +98,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public get roomPhaseHistory(): Array<IRightPanelCard> {
 | 
					    public get roomPhaseHistory(): Array<IRightPanelCard> {
 | 
				
			||||||
        return this.byRoom[this.viewedRoomId]?.history ?? [];
 | 
					        return this.byRoom[this.viewedRoomId ?? ""]?.history ?? [];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
| 
						 | 
					@ -133,7 +133,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Setters
 | 
					    // Setters
 | 
				
			||||||
    public setCard(card: IRightPanelCard, allowClose = true, roomId?: string): void {
 | 
					    public setCard(card: IRightPanelCard, allowClose = true, roomId?: string): void {
 | 
				
			||||||
        const rId = roomId ?? this.viewedRoomId;
 | 
					        const rId = roomId ?? this.viewedRoomId ?? "";
 | 
				
			||||||
        // This function behaves as following:
 | 
					        // This function behaves as following:
 | 
				
			||||||
        // Update state: if the same phase is send but with a state
 | 
					        // Update state: if the same phase is send but with a state
 | 
				
			||||||
        // Set right panel and erase history: if a "different to the current" phase is send (with or without a state)
 | 
					        // Set right panel and erase history: if a "different to the current" phase is send (with or without a state)
 | 
				
			||||||
| 
						 | 
					@ -163,7 +163,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public setCards(cards: IRightPanelCard[], allowClose = true, roomId: string | null = null): void {
 | 
					    public setCards(cards: IRightPanelCard[], allowClose = true, roomId: string | null = null): void {
 | 
				
			||||||
        // This function sets the history of the right panel and shows the right panel if not already visible.
 | 
					        // This function sets the history of the right panel and shows the right panel if not already visible.
 | 
				
			||||||
        const rId = roomId ?? this.viewedRoomId;
 | 
					        const rId = roomId ?? this.viewedRoomId ?? "";
 | 
				
			||||||
        const history = cards.map((c) => ({ phase: c.phase, state: c.state ?? {} }));
 | 
					        const history = cards.map((c) => ({ phase: c.phase, state: c.state ?? {} }));
 | 
				
			||||||
        this.byRoom[rId] = { history, isOpen: true };
 | 
					        this.byRoom[rId] = { history, isOpen: true };
 | 
				
			||||||
        this.show(rId);
 | 
					        this.show(rId);
 | 
				
			||||||
| 
						 | 
					@ -172,7 +172,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Appends a card to the history and shows the right panel if not already visible
 | 
					    // Appends a card to the history and shows the right panel if not already visible
 | 
				
			||||||
    public pushCard(card: IRightPanelCard, allowClose = true, roomId: string | null = null): void {
 | 
					    public pushCard(card: IRightPanelCard, allowClose = true, roomId: string | null = null): void {
 | 
				
			||||||
        const rId = roomId ?? this.viewedRoomId;
 | 
					        const rId = roomId ?? this.viewedRoomId ?? "";
 | 
				
			||||||
        const redirect = this.getVerificationRedirect(card);
 | 
					        const redirect = this.getVerificationRedirect(card);
 | 
				
			||||||
        const targetPhase = redirect?.phase ?? card.phase;
 | 
					        const targetPhase = redirect?.phase ?? card.phase;
 | 
				
			||||||
        const pState = redirect?.state ?? card.state ?? {};
 | 
					        const pState = redirect?.state ?? card.state ?? {};
 | 
				
			||||||
| 
						 | 
					@ -198,7 +198,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public popCard(roomId: string | null = null): IRightPanelCard | undefined {
 | 
					    public popCard(roomId: string | null = null): IRightPanelCard | undefined {
 | 
				
			||||||
        const rId = roomId ?? this.viewedRoomId;
 | 
					        const rId = roomId ?? this.viewedRoomId ?? "";
 | 
				
			||||||
        if (!this.byRoom[rId]) return;
 | 
					        if (!this.byRoom[rId]) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const removedCard = this.byRoom[rId].history.pop();
 | 
					        const removedCard = this.byRoom[rId].history.pop();
 | 
				
			||||||
| 
						 | 
					@ -207,7 +207,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public togglePanel(roomId: string | null): void {
 | 
					    public togglePanel(roomId: string | null): void {
 | 
				
			||||||
        const rId = roomId ?? this.viewedRoomId;
 | 
					        const rId = roomId ?? this.viewedRoomId ?? "";
 | 
				
			||||||
        if (!this.byRoom[rId]) return;
 | 
					        if (!this.byRoom[rId]) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.byRoom[rId].isOpen = !this.byRoom[rId].isOpen;
 | 
					        this.byRoom[rId].isOpen = !this.byRoom[rId].isOpen;
 | 
				
			||||||
| 
						 | 
					@ -215,13 +215,13 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public show(roomId: string | null): void {
 | 
					    public show(roomId: string | null): void {
 | 
				
			||||||
        if (!this.isOpenForRoom(roomId ?? this.viewedRoomId)) {
 | 
					        if (!this.isOpenForRoom(roomId ?? this.viewedRoomId ?? "")) {
 | 
				
			||||||
            this.togglePanel(roomId);
 | 
					            this.togglePanel(roomId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public hide(roomId: string | null): void {
 | 
					    public hide(roomId: string | null): void {
 | 
				
			||||||
        if (this.isOpenForRoom(roomId ?? this.viewedRoomId)) {
 | 
					        if (this.isOpenForRoom(roomId ?? this.viewedRoomId ?? "")) {
 | 
				
			||||||
            this.togglePanel(roomId);
 | 
					            this.togglePanel(roomId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -360,7 +360,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
        // when we're switching to a room, clear out any stale MemberInfo cards
 | 
					        // when we're switching to a room, clear out any stale MemberInfo cards
 | 
				
			||||||
        // in order to fix https://github.com/vector-im/element-web/issues/21487
 | 
					        // in order to fix https://github.com/vector-im/element-web/issues/21487
 | 
				
			||||||
        if (this.currentCard?.phase !== RightPanelPhases.EncryptionPanel) {
 | 
					        if (this.currentCard?.phase !== RightPanelPhases.EncryptionPanel) {
 | 
				
			||||||
            const panel = this.byRoom[this.viewedRoomId];
 | 
					            const panel = this.byRoom[this.viewedRoomId ?? ""];
 | 
				
			||||||
            if (panel?.history) {
 | 
					            if (panel?.history) {
 | 
				
			||||||
                panel.history = panel.history.filter(
 | 
					                panel.history = panel.history.filter(
 | 
				
			||||||
                    (card: IRightPanelCard) =>
 | 
					                    (card: IRightPanelCard) =>
 | 
				
			||||||
| 
						 | 
					@ -380,13 +380,16 @@ export default class RightPanelStore extends ReadyWatchingStore {
 | 
				
			||||||
        // If the right panel stays open mode is used, and the panel was either
 | 
					        // If the right panel stays open mode is used, and the panel was either
 | 
				
			||||||
        // closed or never shown for that room, then force it open and display
 | 
					        // closed or never shown for that room, then force it open and display
 | 
				
			||||||
        // the room member list.
 | 
					        // the room member list.
 | 
				
			||||||
        if (SettingsStore.getValue("feature_right_panel_default_open") && !this.byRoom[this.viewedRoomId]?.isOpen) {
 | 
					        if (
 | 
				
			||||||
 | 
					            SettingsStore.getValue("feature_right_panel_default_open") &&
 | 
				
			||||||
 | 
					            !this.byRoom[this.viewedRoomId ?? ""]?.isOpen
 | 
				
			||||||
 | 
					        ) {
 | 
				
			||||||
            const history = [{ phase: RightPanelPhases.RoomMemberList }];
 | 
					            const history = [{ phase: RightPanelPhases.RoomMemberList }];
 | 
				
			||||||
            const room = this.viewedRoomId ? this.mxClient?.getRoom(this.viewedRoomId) : undefined;
 | 
					            const room = this.viewedRoomId ? this.mxClient?.getRoom(this.viewedRoomId) : undefined;
 | 
				
			||||||
            if (!room?.isSpaceRoom()) {
 | 
					            if (!room?.isSpaceRoom()) {
 | 
				
			||||||
                history.unshift({ phase: RightPanelPhases.RoomSummary });
 | 
					                history.unshift({ phase: RightPanelPhases.RoomSummary });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            this.byRoom[this.viewedRoomId] = {
 | 
					            this.byRoom[this.viewedRoomId ?? ""] = {
 | 
				
			||||||
                isOpen: true,
 | 
					                isOpen: true,
 | 
				
			||||||
                history,
 | 
					                history,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue