You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Add lint for unused locals (#8007)
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2017 New Vector Ltd
 | 
					Copyright 2017 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { EventSubscription } from 'fbemitter';
 | 
					 | 
				
			||||||
import { logger } from "matrix-js-sdk/src/logger";
 | 
					import { logger } from "matrix-js-sdk/src/logger";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import RoomViewStore from './stores/RoomViewStore';
 | 
					import RoomViewStore from './stores/RoomViewStore';
 | 
				
			||||||
@@ -33,11 +32,10 @@ type Listener = (isActive: boolean) => void;
 | 
				
			|||||||
export class ActiveRoomObserver {
 | 
					export class ActiveRoomObserver {
 | 
				
			||||||
    private listeners: {[key: string]: Listener[]} = {};
 | 
					    private listeners: {[key: string]: Listener[]} = {};
 | 
				
			||||||
    private _activeRoomId = RoomViewStore.getRoomId();
 | 
					    private _activeRoomId = RoomViewStore.getRoomId();
 | 
				
			||||||
    private readonly roomStoreToken: EventSubscription;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor() {
 | 
					    constructor() {
 | 
				
			||||||
        // TODO: We could self-destruct when the last listener goes away, or at least stop listening.
 | 
					        // TODO: We could self-destruct when the last listener goes away, or at least stop listening.
 | 
				
			||||||
        this.roomStoreToken = RoomViewStore.addListener(this.onRoomViewStoreUpdate);
 | 
					        RoomViewStore.addListener(this.onRoomViewStoreUpdate);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public get activeRoomId(): string {
 | 
					    public get activeRoomId(): string {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2017 Michael Telatynski <7t3chguy@gmail.com>
 | 
					Copyright 2017 Michael Telatynski <7t3chguy@gmail.com>
 | 
				
			||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -166,7 +166,6 @@ const HEARTBEAT_INTERVAL = 30 * 1000; // seconds
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export class Analytics {
 | 
					export class Analytics {
 | 
				
			||||||
    private baseUrl: URL = null;
 | 
					    private baseUrl: URL = null;
 | 
				
			||||||
    private siteId: string = null;
 | 
					 | 
				
			||||||
    private visitVariables: Record<number, [string, string]> = {}; // {[id: number]: [name: string, value: string]}
 | 
					    private visitVariables: Record<number, [string, string]> = {}; // {[id: number]: [name: string, value: string]}
 | 
				
			||||||
    private firstPage = true;
 | 
					    private firstPage = true;
 | 
				
			||||||
    private heartbeatIntervalID: number = null;
 | 
					    private heartbeatIntervalID: number = null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2015, 2016 OpenMarket Ltd
 | 
					Copyright 2015, 2016 OpenMarket Ltd
 | 
				
			||||||
Copyright 2017, 2018 New Vector Ltd
 | 
					Copyright 2017, 2018 New Vector Ltd
 | 
				
			||||||
Copyright 2019 - 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
 | 
					Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
@@ -125,10 +125,6 @@ export default class CallHandler extends EventEmitter {
 | 
				
			|||||||
    private supportsPstnProtocol = null;
 | 
					    private supportsPstnProtocol = null;
 | 
				
			||||||
    private pstnSupportPrefixed = null; // True if the server only support the prefixed pstn protocol
 | 
					    private pstnSupportPrefixed = null; // True if the server only support the prefixed pstn protocol
 | 
				
			||||||
    private supportsSipNativeVirtual = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
 | 
					    private supportsSipNativeVirtual = null; // im.vector.protocol.sip_virtual and im.vector.protocol.sip_native
 | 
				
			||||||
    private pstnSupportCheckTimer: number;
 | 
					 | 
				
			||||||
    // For rooms we've been invited to, true if they're from virtual user, false if we've checked and they aren't.
 | 
					 | 
				
			||||||
    private invitedRoomsAreVirtual = new Map<string, boolean>();
 | 
					 | 
				
			||||||
    private invitedRoomCheckInProgress = false;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Map of the asserted identity users after we've looked them up using the API.
 | 
					    // Map of the asserted identity users after we've looked them up using the API.
 | 
				
			||||||
    // We need to be be able to determine the mapped room synchronously, so we
 | 
					    // We need to be be able to determine the mapped room synchronously, so we
 | 
				
			||||||
@@ -255,7 +251,7 @@ export default class CallHandler extends EventEmitter {
 | 
				
			|||||||
                logger.log("Failed to check for protocol support and no retries remain: assuming no support", e);
 | 
					                logger.log("Failed to check for protocol support and no retries remain: assuming no support", e);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                logger.log("Failed to check for protocol support: will retry", e);
 | 
					                logger.log("Failed to check for protocol support: will retry", e);
 | 
				
			||||||
                this.pstnSupportCheckTimer = setTimeout(() => {
 | 
					                setTimeout(() => {
 | 
				
			||||||
                    this.checkProtocols(maxTries - 1);
 | 
					                    this.checkProtocols(maxTries - 1);
 | 
				
			||||||
                }, 10000);
 | 
					                }, 10000);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2015, 2016 OpenMarket Ltd
 | 
					Copyright 2015, 2016 OpenMarket Ltd
 | 
				
			||||||
Copyright 2019 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -29,7 +29,6 @@ import { _t } from './languageHandler';
 | 
				
			|||||||
export default class PasswordReset {
 | 
					export default class PasswordReset {
 | 
				
			||||||
    private client: MatrixClient;
 | 
					    private client: MatrixClient;
 | 
				
			||||||
    private clientSecret: string;
 | 
					    private clientSecret: string;
 | 
				
			||||||
    private identityServerDomain: string;
 | 
					 | 
				
			||||||
    private password: string;
 | 
					    private password: string;
 | 
				
			||||||
    private sessionId: string;
 | 
					    private sessionId: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,7 +43,6 @@ export default class PasswordReset {
 | 
				
			|||||||
            idBaseUrl: identityUrl,
 | 
					            idBaseUrl: identityUrl,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        this.clientSecret = this.client.generateClientSecret();
 | 
					        this.clientSecret = this.client.generateClientSecret();
 | 
				
			||||||
        this.identityServerDomain = identityUrl ? identityUrl.split("://")[1] : null;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { MatrixClient } from "matrix-js-sdk/src/client";
 | 
					 | 
				
			||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
 | 
					import { MatrixEvent } from "matrix-js-sdk/src/models/event";
 | 
				
			||||||
import { Room } from "matrix-js-sdk/src/models/room";
 | 
					import { Room } from "matrix-js-sdk/src/models/room";
 | 
				
			||||||
import { EventType } from "matrix-js-sdk/src/@types/event";
 | 
					import { EventType } from "matrix-js-sdk/src/@types/event";
 | 
				
			||||||
@@ -49,7 +48,7 @@ export class PlaybackQueue {
 | 
				
			|||||||
    private currentPlaybackId: string; // event ID, broken out from above for ease of use
 | 
					    private currentPlaybackId: string; // event ID, broken out from above for ease of use
 | 
				
			||||||
    private recentFullPlays = new Set<string>(); // event IDs
 | 
					    private recentFullPlays = new Set<string>(); // event IDs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(private client: MatrixClient, private room: Room) {
 | 
					    constructor(private room: Room) {
 | 
				
			||||||
        this.loadClocks();
 | 
					        this.loadClocks();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        RoomViewStore.addListener(() => {
 | 
					        RoomViewStore.addListener(() => {
 | 
				
			||||||
@@ -71,7 +70,7 @@ export class PlaybackQueue {
 | 
				
			|||||||
        if (PlaybackQueue.queues.has(room.roomId)) {
 | 
					        if (PlaybackQueue.queues.has(room.roomId)) {
 | 
				
			||||||
            return PlaybackQueue.queues.get(room.roomId);
 | 
					            return PlaybackQueue.queues.get(room.roomId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const queue = new PlaybackQueue(cli, room);
 | 
					        const queue = new PlaybackQueue(room);
 | 
				
			||||||
        PlaybackQueue.queues.set(room.roomId, queue);
 | 
					        PlaybackQueue.queues.set(room.roomId, queue);
 | 
				
			||||||
        return queue;
 | 
					        return queue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,10 +177,6 @@ export default class InteractiveAuthComponent extends React.Component<IProps, IS
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private tryContinue = (): void => {
 | 
					 | 
				
			||||||
        this.stageComponent.current?.tryContinue?.();
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private authStateUpdated = (stageType: AuthType, stageState: IStageStatus): void => {
 | 
					    private authStateUpdated = (stageType: AuthType, stageState: IStageStatus): void => {
 | 
				
			||||||
        const oldStage = this.state.authStage;
 | 
					        const oldStage = this.state.authStage;
 | 
				
			||||||
        this.setState({
 | 
					        this.setState({
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2015 - 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2015 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -58,6 +58,7 @@ import AudioFeedArrayForCall from '../views/voip/AudioFeedArrayForCall';
 | 
				
			|||||||
import { OwnProfileStore } from '../../stores/OwnProfileStore';
 | 
					import { OwnProfileStore } from '../../stores/OwnProfileStore';
 | 
				
			||||||
import { UPDATE_EVENT } from "../../stores/AsyncStore";
 | 
					import { UPDATE_EVENT } from "../../stores/AsyncStore";
 | 
				
			||||||
import RoomView from './RoomView';
 | 
					import RoomView from './RoomView';
 | 
				
			||||||
 | 
					import type { RoomView as RoomViewType } from './RoomView';
 | 
				
			||||||
import ToastContainer from './ToastContainer';
 | 
					import ToastContainer from './ToastContainer';
 | 
				
			||||||
import MyGroups from "./MyGroups";
 | 
					import MyGroups from "./MyGroups";
 | 
				
			||||||
import UserView from "./UserView";
 | 
					import UserView from "./UserView";
 | 
				
			||||||
@@ -139,7 +140,7 @@ class LoggedInView extends React.Component<IProps, IState> {
 | 
				
			|||||||
    static displayName = 'LoggedInView';
 | 
					    static displayName = 'LoggedInView';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected readonly _matrixClient: MatrixClient;
 | 
					    protected readonly _matrixClient: MatrixClient;
 | 
				
			||||||
    protected readonly _roomView: React.RefObject<any>;
 | 
					    protected readonly _roomView: React.RefObject<RoomViewType>;
 | 
				
			||||||
    protected readonly _resizeContainer: React.RefObject<HTMLDivElement>;
 | 
					    protected readonly _resizeContainer: React.RefObject<HTMLDivElement>;
 | 
				
			||||||
    protected readonly resizeHandler: React.RefObject<HTMLDivElement>;
 | 
					    protected readonly resizeHandler: React.RefObject<HTMLDivElement>;
 | 
				
			||||||
    protected layoutWatcherRef: string;
 | 
					    protected layoutWatcherRef: string;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -229,7 +229,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
 | 
				
			|||||||
    private firstSyncPromise: IDeferred<void>;
 | 
					    private firstSyncPromise: IDeferred<void>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private screenAfterLogin?: IScreen;
 | 
					    private screenAfterLogin?: IScreen;
 | 
				
			||||||
    private pageChanging: boolean;
 | 
					 | 
				
			||||||
    private tokenLogin?: boolean;
 | 
					    private tokenLogin?: boolean;
 | 
				
			||||||
    private accountPassword?: string;
 | 
					    private accountPassword?: string;
 | 
				
			||||||
    private accountPasswordTimer?: number;
 | 
					    private accountPasswordTimer?: number;
 | 
				
			||||||
@@ -284,8 +283,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
 | 
				
			|||||||
        this.prevWindowWidth = UIStore.instance.windowWidth || 1000;
 | 
					        this.prevWindowWidth = UIStore.instance.windowWidth || 1000;
 | 
				
			||||||
        UIStore.instance.on(UI_EVENTS.Resize, this.handleResize);
 | 
					        UIStore.instance.on(UI_EVENTS.Resize, this.handleResize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.pageChanging = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // For PersistentElement
 | 
					        // For PersistentElement
 | 
				
			||||||
        this.state.resizeNotifier.on("middlePanelResized", this.dispatchTimelineResize);
 | 
					        this.state.resizeNotifier.on("middlePanelResized", this.dispatchTimelineResize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,7 +78,6 @@ interface IState {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
@replaceableComponent("structures.RoomDirectory")
 | 
					@replaceableComponent("structures.RoomDirectory")
 | 
				
			||||||
export default class RoomDirectory extends React.Component<IProps, IState> {
 | 
					export default class RoomDirectory extends React.Component<IProps, IState> {
 | 
				
			||||||
    private readonly startTime: number;
 | 
					 | 
				
			||||||
    private unmounted = false;
 | 
					    private unmounted = false;
 | 
				
			||||||
    private nextBatch: string = null;
 | 
					    private nextBatch: string = null;
 | 
				
			||||||
    private filterTimeout: number;
 | 
					    private filterTimeout: number;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1681,8 +1681,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * We pass it down to the scroll panel.
 | 
					     * We pass it down to the scroll panel.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private handleScrollKey = ev => {
 | 
					    public handleScrollKey = ev => {
 | 
				
			||||||
        let panel;
 | 
					        let panel: ScrollPanel | TimelinePanel;
 | 
				
			||||||
        if (this.searchResultsPanel.current) {
 | 
					        if (this.searchResultsPanel.current) {
 | 
				
			||||||
            panel = this.searchResultsPanel.current;
 | 
					            panel = this.searchResultsPanel.current;
 | 
				
			||||||
        } else if (this.messagePanel) {
 | 
					        } else if (this.messagePanel) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -326,10 +326,6 @@ export class TermsAuthEntry extends React.Component<ITermsAuthEntryProps, ITerms
 | 
				
			|||||||
        this.props.onPhaseChange(DEFAULT_PHASE);
 | 
					        this.props.onPhaseChange(DEFAULT_PHASE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public tryContinue = () => {
 | 
					 | 
				
			||||||
        this.trySubmit();
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private togglePolicy(policyId: string) {
 | 
					    private togglePolicy(policyId: string) {
 | 
				
			||||||
        const newToggles = {};
 | 
					        const newToggles = {};
 | 
				
			||||||
        for (const policy of this.state.policies) {
 | 
					        for (const policy of this.state.policies) {
 | 
				
			||||||
@@ -832,7 +828,6 @@ export interface IStageComponentProps extends IAuthEntryProps {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IStageComponent extends React.ComponentClass<React.PropsWithRef<IStageComponentProps>> {
 | 
					export interface IStageComponent extends React.ComponentClass<React.PropsWithRef<IStageComponentProps>> {
 | 
				
			||||||
    tryContinue?(): void;
 | 
					 | 
				
			||||||
    attemptFailed?(): void;
 | 
					    attemptFailed?(): void;
 | 
				
			||||||
    focus?(): void;
 | 
					    focus?(): void;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2018, 2019 New Vector Ltd
 | 
					Copyright 2018, 2019 New Vector Ltd
 | 
				
			||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -81,11 +81,6 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private onSettingsLinkClick = (): void => {
 | 
					 | 
				
			||||||
        // close dialog
 | 
					 | 
				
			||||||
        this.props.onFinished(true);
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private onExportE2eKeysClicked = (): void => {
 | 
					    private onExportE2eKeysClicked = (): void => {
 | 
				
			||||||
        Modal.createTrackedDialogAsync('Export E2E Keys', '',
 | 
					        Modal.createTrackedDialogAsync('Export E2E Keys', '',
 | 
				
			||||||
            import(
 | 
					            import(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2016 - 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2016 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -28,6 +28,7 @@ import {
 | 
				
			|||||||
    VectorPushRulesDefinitions,
 | 
					    VectorPushRulesDefinitions,
 | 
				
			||||||
    VectorState,
 | 
					    VectorState,
 | 
				
			||||||
} from "../../../notifications";
 | 
					} from "../../../notifications";
 | 
				
			||||||
 | 
					import type { VectorPushRuleDefinition } from "../../../notifications";
 | 
				
			||||||
import { _t, TranslatedString } from "../../../languageHandler";
 | 
					import { _t, TranslatedString } from "../../../languageHandler";
 | 
				
			||||||
import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
 | 
					import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
 | 
				
			||||||
import SettingsStore from "../../../settings/SettingsStore";
 | 
					import SettingsStore from "../../../settings/SettingsStore";
 | 
				
			||||||
@@ -209,7 +210,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
 | 
				
			|||||||
        for (const category of vectorCategories) {
 | 
					        for (const category of vectorCategories) {
 | 
				
			||||||
            preparedNewState.vectorPushRules[category] = [];
 | 
					            preparedNewState.vectorPushRules[category] = [];
 | 
				
			||||||
            for (const rule of defaultRules[category]) {
 | 
					            for (const rule of defaultRules[category]) {
 | 
				
			||||||
                const definition = VectorPushRulesDefinitions[rule.rule_id];
 | 
					                const definition: VectorPushRuleDefinition = VectorPushRulesDefinitions[rule.rule_id];
 | 
				
			||||||
                const vectorState = definition.ruleToVectorState(rule);
 | 
					                const vectorState = definition.ruleToVectorState(rule);
 | 
				
			||||||
                preparedNewState.vectorPushRules[category].push({
 | 
					                preparedNewState.vectorPushRules[category].push({
 | 
				
			||||||
                    ruleId: rule.rule_id,
 | 
					                    ruleId: rule.rule_id,
 | 
				
			||||||
@@ -356,7 +357,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                const definition = VectorPushRulesDefinitions[rule.ruleId];
 | 
					                const definition: VectorPushRuleDefinition = VectorPushRulesDefinitions[rule.ruleId];
 | 
				
			||||||
                const actions = definition.vectorStateToActions[checkedState];
 | 
					                const actions = definition.vectorStateToActions[checkedState];
 | 
				
			||||||
                if (!actions) {
 | 
					                if (!actions) {
 | 
				
			||||||
                    await cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false);
 | 
					                    await cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2019-2022 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -100,18 +100,6 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private showSpoiler = (event) => {
 | 
					 | 
				
			||||||
        const target = event.target;
 | 
					 | 
				
			||||||
        target.innerHTML = target.getAttribute('data-spoiler');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const range = document.createRange();
 | 
					 | 
				
			||||||
        range.selectNodeContents(target);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        const selection = window.getSelection();
 | 
					 | 
				
			||||||
        selection.removeAllRanges();
 | 
					 | 
				
			||||||
        selection.addRange(range);
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private renderLegal() {
 | 
					    private renderLegal() {
 | 
				
			||||||
        const tocLinks = SdkConfig.get().terms_and_conditions_links;
 | 
					        const tocLinks = SdkConfig.get().terms_and_conditions_links;
 | 
				
			||||||
        if (!tocLinks) return null;
 | 
					        if (!tocLinks) return null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2019 New Vector Ltd
 | 
					Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -147,14 +146,6 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private onGoToUserProfileClick = (): void => {
 | 
					 | 
				
			||||||
        dis.dispatch({
 | 
					 | 
				
			||||||
            action: 'view_user_info',
 | 
					 | 
				
			||||||
            userId: MatrixClientPeg.get().getUserId(),
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        this.props.closeSettingsFn();
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private onUserUnignored = async (userId: string): Promise<void> => {
 | 
					    private onUserUnignored = async (userId: string): Promise<void> => {
 | 
				
			||||||
        const { ignoredUserIds, waitingUnignored } = this.state;
 | 
					        const { ignoredUserIds, waitingUnignored } = this.state;
 | 
				
			||||||
        const currentlyIgnoredUserIds = ignoredUserIds.filter(e => !waitingUnignored.includes(e));
 | 
					        const currentlyIgnoredUserIds = ignoredUserIds.filter(e => !waitingUnignored.includes(e));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -205,7 +205,7 @@ const CreateSpaceButton = ({
 | 
				
			|||||||
}: Pick<IInnerSpacePanelProps, "isPanelCollapsed" | "setPanelCollapsed">) => {
 | 
					}: Pick<IInnerSpacePanelProps, "isPanelCollapsed" | "setPanelCollapsed">) => {
 | 
				
			||||||
    // We don't need the handle as we position the menu in a constant location
 | 
					    // We don't need the handle as we position the menu in a constant location
 | 
				
			||||||
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
					    // eslint-disable-next-line @typescript-eslint/no-unused-vars
 | 
				
			||||||
    const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu<void>();
 | 
					    const [menuDisplayed, _handle, openMenu, closeMenu] = useContextMenu<void>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    useEffect(() => {
 | 
					    useEffect(() => {
 | 
				
			||||||
        if (!isPanelCollapsed && menuDisplayed) {
 | 
					        if (!isPanelCollapsed && menuDisplayed) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -42,8 +42,6 @@ interface IState {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
@replaceableComponent("views.voip.CallViewForRoom")
 | 
					@replaceableComponent("views.voip.CallViewForRoom")
 | 
				
			||||||
export default class CallViewForRoom extends React.Component<IProps, IState> {
 | 
					export default class CallViewForRoom extends React.Component<IProps, IState> {
 | 
				
			||||||
    private dispatcherRef: string;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    constructor(props: IProps) {
 | 
					    constructor(props: IProps) {
 | 
				
			||||||
        super(props);
 | 
					        super(props);
 | 
				
			||||||
        this.state = {
 | 
					        this.state = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2016 - 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2016 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
				
			|||||||
limitations under the License.
 | 
					limitations under the License.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { PushRuleAction, PushRuleKind } from "matrix-js-sdk/src/@types/PushRules";
 | 
					import { IAnnotatedPushRule, PushRuleAction } from "matrix-js-sdk/src/@types/PushRules";
 | 
				
			||||||
import { logger } from "matrix-js-sdk/src/logger";
 | 
					import { logger } from "matrix-js-sdk/src/logger";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { _td } from '../languageHandler';
 | 
					import { _td } from '../languageHandler';
 | 
				
			||||||
@@ -26,32 +26,29 @@ type StateToActionsMap = {
 | 
				
			|||||||
    [state in VectorState]?: PushRuleAction[];
 | 
					    [state in VectorState]?: PushRuleAction[];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IProps {
 | 
					interface IVectorPushRuleDefinition {
 | 
				
			||||||
    kind: PushRuleKind;
 | 
					 | 
				
			||||||
    description: string;
 | 
					    description: string;
 | 
				
			||||||
    vectorStateToActions: StateToActionsMap;
 | 
					    vectorStateToActions: StateToActionsMap;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class VectorPushRuleDefinition {
 | 
					class VectorPushRuleDefinition {
 | 
				
			||||||
    private kind: PushRuleKind;
 | 
					    public readonly description: string;
 | 
				
			||||||
    private description: string;
 | 
					 | 
				
			||||||
    public readonly vectorStateToActions: StateToActionsMap;
 | 
					    public readonly vectorStateToActions: StateToActionsMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(opts: IProps) {
 | 
					    constructor(opts: IVectorPushRuleDefinition) {
 | 
				
			||||||
        this.kind = opts.kind;
 | 
					 | 
				
			||||||
        this.description = opts.description;
 | 
					        this.description = opts.description;
 | 
				
			||||||
        this.vectorStateToActions = opts.vectorStateToActions;
 | 
					        this.vectorStateToActions = opts.vectorStateToActions;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Translate the rule actions and its enabled value into vector state
 | 
					    // Translate the rule actions and its enabled value into vector state
 | 
				
			||||||
    public ruleToVectorState(rule): VectorPushRuleDefinition {
 | 
					    public ruleToVectorState(rule: IAnnotatedPushRule): VectorState {
 | 
				
			||||||
        let enabled = false;
 | 
					        let enabled = false;
 | 
				
			||||||
        if (rule) {
 | 
					        if (rule) {
 | 
				
			||||||
            enabled = rule.enabled;
 | 
					            enabled = rule.enabled;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (const stateKey in PushRuleVectorState.states) { // eslint-disable-line guard-for-in
 | 
					        for (const stateKey in PushRuleVectorState.states) { // eslint-disable-line guard-for-in
 | 
				
			||||||
            const state = PushRuleVectorState.states[stateKey];
 | 
					            const state: VectorState = PushRuleVectorState.states[stateKey];
 | 
				
			||||||
            const vectorStateToActions = this.vectorStateToActions[state];
 | 
					            const vectorStateToActions = this.vectorStateToActions[state];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!vectorStateToActions) {
 | 
					            if (!vectorStateToActions) {
 | 
				
			||||||
@@ -78,6 +75,7 @@ class VectorPushRuleDefinition {
 | 
				
			|||||||
        return undefined;
 | 
					        return undefined;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					export type { VectorPushRuleDefinition };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * The descriptions of rules managed by the Vector UI.
 | 
					 * The descriptions of rules managed by the Vector UI.
 | 
				
			||||||
@@ -85,7 +83,6 @@ class VectorPushRuleDefinition {
 | 
				
			|||||||
export const VectorPushRulesDefinitions = {
 | 
					export const VectorPushRulesDefinitions = {
 | 
				
			||||||
    // Messages containing user's display name
 | 
					    // Messages containing user's display name
 | 
				
			||||||
    ".m.rule.contains_display_name": new VectorPushRuleDefinition({
 | 
					    ".m.rule.contains_display_name": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Override,
 | 
					 | 
				
			||||||
        description: _td("Messages containing my display name"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Messages containing my display name"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
					        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -96,7 +93,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Messages containing user's username (localpart/MXID)
 | 
					    // Messages containing user's username (localpart/MXID)
 | 
				
			||||||
    ".m.rule.contains_user_name": new VectorPushRuleDefinition({
 | 
					    ".m.rule.contains_user_name": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Override,
 | 
					 | 
				
			||||||
        description: _td("Messages containing my username"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Messages containing my username"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
					        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -107,7 +103,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Messages containing @room
 | 
					    // Messages containing @room
 | 
				
			||||||
    ".m.rule.roomnotif": new VectorPushRuleDefinition({
 | 
					    ".m.rule.roomnotif": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Override,
 | 
					 | 
				
			||||||
        description: _td("Messages containing @room"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Messages containing @room"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
					        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -118,7 +113,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Messages just sent to the user in a 1:1 room
 | 
					    // Messages just sent to the user in a 1:1 room
 | 
				
			||||||
    ".m.rule.room_one_to_one": new VectorPushRuleDefinition({
 | 
					    ".m.rule.room_one_to_one": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Underride,
 | 
					 | 
				
			||||||
        description: _td("Messages in one-to-one chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Messages in one-to-one chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -129,7 +123,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Encrypted messages just sent to the user in a 1:1 room
 | 
					    // Encrypted messages just sent to the user in a 1:1 room
 | 
				
			||||||
    ".m.rule.encrypted_room_one_to_one": new VectorPushRuleDefinition({
 | 
					    ".m.rule.encrypted_room_one_to_one": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Underride,
 | 
					 | 
				
			||||||
        description: _td("Encrypted messages in one-to-one chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Encrypted messages in one-to-one chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -142,7 +135,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
    // 1:1 room messages are catched by the .m.rule.room_one_to_one rule if any defined
 | 
					    // 1:1 room messages are catched by the .m.rule.room_one_to_one rule if any defined
 | 
				
			||||||
    // By opposition, all other room messages are from group chat rooms.
 | 
					    // By opposition, all other room messages are from group chat rooms.
 | 
				
			||||||
    ".m.rule.message": new VectorPushRuleDefinition({
 | 
					    ".m.rule.message": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Underride,
 | 
					 | 
				
			||||||
        description: _td("Messages in group chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Messages in group chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -155,7 +147,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
    // Encrypted 1:1 room messages are catched by the .m.rule.encrypted_room_one_to_one rule if any defined
 | 
					    // Encrypted 1:1 room messages are catched by the .m.rule.encrypted_room_one_to_one rule if any defined
 | 
				
			||||||
    // By opposition, all other room messages are from group chat rooms.
 | 
					    // By opposition, all other room messages are from group chat rooms.
 | 
				
			||||||
    ".m.rule.encrypted": new VectorPushRuleDefinition({
 | 
					    ".m.rule.encrypted": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Underride,
 | 
					 | 
				
			||||||
        description: _td("Encrypted messages in group chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Encrypted messages in group chats"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -166,7 +157,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Invitation for the user
 | 
					    // Invitation for the user
 | 
				
			||||||
    ".m.rule.invite_for_me": new VectorPushRuleDefinition({
 | 
					    ".m.rule.invite_for_me": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Underride,
 | 
					 | 
				
			||||||
        description: _td("When I'm invited to a room"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("When I'm invited to a room"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -177,7 +167,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Incoming call
 | 
					    // Incoming call
 | 
				
			||||||
    ".m.rule.call": new VectorPushRuleDefinition({
 | 
					    ".m.rule.call": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Underride,
 | 
					 | 
				
			||||||
        description: _td("Call invitation"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Call invitation"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
@@ -188,7 +177,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Notifications from bots
 | 
					    // Notifications from bots
 | 
				
			||||||
    ".m.rule.suppress_notices": new VectorPushRuleDefinition({
 | 
					    ".m.rule.suppress_notices": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Override,
 | 
					 | 
				
			||||||
        description: _td("Messages sent by bot"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("Messages sent by bot"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: {
 | 
					        vectorStateToActions: {
 | 
				
			||||||
            // .m.rule.suppress_notices is a "negative" rule, we have to invert its enabled value for vector UI
 | 
					            // .m.rule.suppress_notices is a "negative" rule, we have to invert its enabled value for vector UI
 | 
				
			||||||
@@ -200,7 +188,6 @@ export const VectorPushRulesDefinitions = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Room upgrades (tombstones)
 | 
					    // Room upgrades (tombstones)
 | 
				
			||||||
    ".m.rule.tombstone": new VectorPushRuleDefinition({
 | 
					    ".m.rule.tombstone": new VectorPushRuleDefinition({
 | 
				
			||||||
        kind: PushRuleKind.Override,
 | 
					 | 
				
			||||||
        description: _td("When rooms are upgraded"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
					        description: _td("When rooms are upgraded"), // passed through _t() translation in src/components/views/settings/Notifications.js
 | 
				
			||||||
        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
					        vectorStateToActions: { // The actions for each vector state, or null to disable the rule.
 | 
				
			||||||
            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
					            [VectorState.On]: StandardActions.ACTION_NOTIFY,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -17,7 +17,6 @@ limitations under the License.
 | 
				
			|||||||
import { Room } from "matrix-js-sdk/src/models/room";
 | 
					import { Room } from "matrix-js-sdk/src/models/room";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { NotificationColor } from "./NotificationColor";
 | 
					import { NotificationColor } from "./NotificationColor";
 | 
				
			||||||
import { TagID } from "../room-list/models";
 | 
					 | 
				
			||||||
import { arrayDiff } from "../../utils/arrays";
 | 
					import { arrayDiff } from "../../utils/arrays";
 | 
				
			||||||
import { RoomNotificationState } from "./RoomNotificationState";
 | 
					import { RoomNotificationState } from "./RoomNotificationState";
 | 
				
			||||||
import { NotificationState, NotificationStateEvents } from "./NotificationState";
 | 
					import { NotificationState, NotificationStateEvents } from "./NotificationState";
 | 
				
			||||||
@@ -28,7 +27,7 @@ export class ListNotificationState extends NotificationState {
 | 
				
			|||||||
    private rooms: Room[] = [];
 | 
					    private rooms: Room[] = [];
 | 
				
			||||||
    private states: { [roomId: string]: RoomNotificationState } = {};
 | 
					    private states: { [roomId: string]: RoomNotificationState } = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(private byTileCount = false, private tagId: TagID, private getRoomFn: FetchRoomFn) {
 | 
					    constructor(private byTileCount = false, private getRoomFn: FetchRoomFn) {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2020 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -68,7 +68,7 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient<IState> {
 | 
				
			|||||||
        const getRoomFn: FetchRoomFn = (room: Room) => {
 | 
					        const getRoomFn: FetchRoomFn = (room: Room) => {
 | 
				
			||||||
            return this.getRoomState(room);
 | 
					            return this.getRoomState(room);
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        const state = new ListNotificationState(useTileCount, tagId, getRoomFn);
 | 
					        const state = new ListNotificationState(useTileCount, getRoomFn);
 | 
				
			||||||
        this.listMap.set(tagId, state);
 | 
					        this.listMap.set(tagId, state);
 | 
				
			||||||
        return state;
 | 
					        return state;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -26,7 +26,7 @@ export class SpaceNotificationState extends NotificationState {
 | 
				
			|||||||
    public rooms: Room[] = []; // exposed only for tests
 | 
					    public rooms: Room[] = []; // exposed only for tests
 | 
				
			||||||
    private states: { [spaceId: string]: RoomNotificationState } = {};
 | 
					    private states: { [spaceId: string]: RoomNotificationState } = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(private spaceId: string | symbol, private getRoomFn: FetchRoomFn) {
 | 
					    constructor(private getRoomFn: FetchRoomFn) {
 | 
				
			||||||
        super();
 | 
					        super();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2018-2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2018 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -64,8 +64,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
 | 
				
			|||||||
    private algorithm = new Algorithm();
 | 
					    private algorithm = new Algorithm();
 | 
				
			||||||
    private filterConditions: IFilterCondition[] = [];
 | 
					    private filterConditions: IFilterCondition[] = [];
 | 
				
			||||||
    private prefilterConditions: IFilterCondition[] = [];
 | 
					    private prefilterConditions: IFilterCondition[] = [];
 | 
				
			||||||
    private tagWatcher: TagWatcher;
 | 
					 | 
				
			||||||
    private spaceWatcher: SpaceWatcher;
 | 
					 | 
				
			||||||
    private updateFn = new MarkedExecution(() => {
 | 
					    private updateFn = new MarkedExecution(() => {
 | 
				
			||||||
        for (const tagId of Object.keys(this.orderedLists)) {
 | 
					        for (const tagId of Object.keys(this.orderedLists)) {
 | 
				
			||||||
            RoomNotificationStateStore.instance.getListState(tagId).setRooms(this.orderedLists[tagId]);
 | 
					            RoomNotificationStateStore.instance.getListState(tagId).setRooms(this.orderedLists[tagId]);
 | 
				
			||||||
@@ -83,10 +81,11 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private setupWatchers() {
 | 
					    private setupWatchers() {
 | 
				
			||||||
 | 
					        // TODO: Maybe destroy these if this class supports destruction
 | 
				
			||||||
        if (SpaceStore.spacesEnabled) {
 | 
					        if (SpaceStore.spacesEnabled) {
 | 
				
			||||||
            this.spaceWatcher = new SpaceWatcher(this);
 | 
					            new SpaceWatcher(this);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            this.tagWatcher = new TagWatcher(this);
 | 
					            new TagWatcher(this);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,7 +105,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
 | 
				
			|||||||
        this.filterConditions = [];
 | 
					        this.filterConditions = [];
 | 
				
			||||||
        this.prefilterConditions = [];
 | 
					        this.prefilterConditions = [];
 | 
				
			||||||
        this.initialListsGenerated = false;
 | 
					        this.initialListsGenerated = false;
 | 
				
			||||||
        this.setupWatchers();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.algorithm.off(LIST_UPDATED_EVENT, this.onAlgorithmListUpdated);
 | 
					        this.algorithm.off(LIST_UPDATED_EVENT, this.onAlgorithmListUpdated);
 | 
				
			||||||
        this.algorithm.off(FILTER_CHANGED, this.onAlgorithmListUpdated);
 | 
					        this.algorithm.off(FILTER_CHANGED, this.onAlgorithmListUpdated);
 | 
				
			||||||
@@ -131,7 +129,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
 | 
				
			|||||||
        this.algorithm.on(FILTER_CHANGED, this.onAlgorithmFilterUpdated);
 | 
					        this.algorithm.on(FILTER_CHANGED, this.onAlgorithmFilterUpdated);
 | 
				
			||||||
        this.setupWatchers();
 | 
					        this.setupWatchers();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Update any settings here, as some may have happened before we were logically ready.
 | 
					 | 
				
			||||||
        // Update any settings here, as some may have happened before we were logically ready.
 | 
					        // Update any settings here, as some may have happened before we were logically ready.
 | 
				
			||||||
        logger.log("Regenerating room lists: Startup");
 | 
					        logger.log("Regenerating room lists: Startup");
 | 
				
			||||||
        await this.readAndCacheSettingsFromStore();
 | 
					        await this.readAndCacheSettingsFromStore();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
Copyright 2021 The Matrix.org Foundation C.I.C.
 | 
					Copyright 2021 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
you may not use this file except in compliance with the License.
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -1236,7 +1236,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
 | 
				
			|||||||
            return this.notificationStateMap.get(key);
 | 
					            return this.notificationStateMap.get(key);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const state = new SpaceNotificationState(key, getRoomFn);
 | 
					        const state = new SpaceNotificationState(getRoomFn);
 | 
				
			||||||
        this.notificationStateMap.set(key, state);
 | 
					        this.notificationStateMap.set(key, state);
 | 
				
			||||||
        return state;
 | 
					        return state;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright 2020 - 2021 The Matrix.org Foundation C.I.C.
 | 
					 * Copyright 2020 - 2022 The Matrix.org Foundation C.I.C.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 * you may not use this file except in compliance with the License.
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
@@ -238,10 +238,6 @@ export class StopGapWidget extends EventEmitter {
 | 
				
			|||||||
        return !!this.messaging;
 | 
					        return !!this.messaging;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private get widgetId() {
 | 
					 | 
				
			||||||
        return this.messaging.widget.id;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private onOpenModal = async (ev: CustomEvent<IModalWidgetOpenRequest>) => {
 | 
					    private onOpenModal = async (ev: CustomEvent<IModalWidgetOpenRequest>) => {
 | 
				
			||||||
        ev.preventDefault();
 | 
					        ev.preventDefault();
 | 
				
			||||||
        if (ModalWidgetStore.instance.canOpenModalWidget()) {
 | 
					        if (ModalWidgetStore.instance.canOpenModalWidget()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@
 | 
				
			|||||||
    "moduleResolution": "node",
 | 
					    "moduleResolution": "node",
 | 
				
			||||||
    "target": "es2016",
 | 
					    "target": "es2016",
 | 
				
			||||||
    "noImplicitAny": false,
 | 
					    "noImplicitAny": false,
 | 
				
			||||||
 | 
					    "noUnusedLocals": true,
 | 
				
			||||||
    "sourceMap": false,
 | 
					    "sourceMap": false,
 | 
				
			||||||
    "outDir": "./lib",
 | 
					    "outDir": "./lib",
 | 
				
			||||||
    "declaration": true,
 | 
					    "declaration": true,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user