From 65691202f762c6ec5d32fff2836c58b6aeb42985 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 9 Mar 2022 12:05:16 +0000 Subject: [PATCH] Add lint for unused locals (#8007) --- src/ActiveRoomObserver.ts | 6 ++-- src/Analytics.tsx | 3 +- src/CallHandler.tsx | 8 ++--- src/PasswordReset.ts | 4 +-- src/audio/PlaybackQueue.ts | 7 ++--- src/components/structures/InteractiveAuth.tsx | 4 --- src/components/structures/LoggedInView.tsx | 5 ++-- src/components/structures/MatrixChat.tsx | 3 -- src/components/structures/RoomDirectory.tsx | 1 - src/components/structures/RoomView.tsx | 4 +-- .../auth/InteractiveAuthEntryComponents.tsx | 5 ---- src/components/views/dialogs/LogoutDialog.tsx | 7 +---- .../views/settings/Notifications.tsx | 7 +++-- .../tabs/user/HelpUserSettingsTab.tsx | 14 +-------- .../tabs/user/SecurityUserSettingsTab.tsx | 11 +------ src/components/views/spaces/SpacePanel.tsx | 4 +-- src/components/views/voip/CallViewForRoom.tsx | 4 +-- .../VectorPushRulesDefinitions.ts | 29 +++++-------------- .../notifications/ListNotificationState.ts | 5 ++-- .../RoomNotificationStateStore.ts | 4 +-- .../notifications/SpaceNotificationState.ts | 4 +-- src/stores/room-list/RoomListStore.ts | 11 +++---- src/stores/spaces/SpaceStore.ts | 4 +-- src/stores/widgets/StopGapWidget.ts | 6 +--- tsconfig.json | 1 + 25 files changed, 46 insertions(+), 115 deletions(-) diff --git a/src/ActiveRoomObserver.ts b/src/ActiveRoomObserver.ts index 4da0a6eac3..ef64192203 100644 --- a/src/ActiveRoomObserver.ts +++ b/src/ActiveRoomObserver.ts @@ -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"); 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. */ -import { EventSubscription } from 'fbemitter'; import { logger } from "matrix-js-sdk/src/logger"; import RoomViewStore from './stores/RoomViewStore'; @@ -33,11 +32,10 @@ type Listener = (isActive: boolean) => void; export class ActiveRoomObserver { private listeners: {[key: string]: Listener[]} = {}; private _activeRoomId = RoomViewStore.getRoomId(); - private readonly roomStoreToken: EventSubscription; constructor() { // 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 { diff --git a/src/Analytics.tsx b/src/Analytics.tsx index 09cb78d980..d7759562b1 100644 --- a/src/Analytics.tsx +++ b/src/Analytics.tsx @@ -1,6 +1,6 @@ /* 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"); 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 { private baseUrl: URL = null; - private siteId: string = null; private visitVariables: Record = {}; // {[id: number]: [name: string, value: string]} private firstPage = true; private heartbeatIntervalID: number = null; diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index 60094262ed..07fc0bb115 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -1,7 +1,7 @@ /* Copyright 2015, 2016 OpenMarket 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 Licensed under the Apache License, Version 2.0 (the "License"); @@ -125,10 +125,6 @@ export default class CallHandler extends EventEmitter { private supportsPstnProtocol = null; 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 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(); - private invitedRoomCheckInProgress = false; // 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 @@ -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); } else { logger.log("Failed to check for protocol support: will retry", e); - this.pstnSupportCheckTimer = setTimeout(() => { + setTimeout(() => { this.checkProtocols(maxTries - 1); }, 10000); } diff --git a/src/PasswordReset.ts b/src/PasswordReset.ts index 7b0b6f9f84..f5d9ab77dc 100644 --- a/src/PasswordReset.ts +++ b/src/PasswordReset.ts @@ -1,6 +1,6 @@ /* 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"); you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import { _t } from './languageHandler'; export default class PasswordReset { private client: MatrixClient; private clientSecret: string; - private identityServerDomain: string; private password: string; private sessionId: string; @@ -44,7 +43,6 @@ export default class PasswordReset { idBaseUrl: identityUrl, }); this.clientSecret = this.client.generateClientSecret(); - this.identityServerDomain = identityUrl ? identityUrl.split("://")[1] : null; } /** diff --git a/src/audio/PlaybackQueue.ts b/src/audio/PlaybackQueue.ts index 3b1b001bb9..d470b6b94c 100644 --- a/src/audio/PlaybackQueue.ts +++ b/src/audio/PlaybackQueue.ts @@ -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"); 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. */ -import { MatrixClient } from "matrix-js-sdk/src/client"; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { Room } from "matrix-js-sdk/src/models/room"; 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 recentFullPlays = new Set(); // event IDs - constructor(private client: MatrixClient, private room: Room) { + constructor(private room: Room) { this.loadClocks(); RoomViewStore.addListener(() => { @@ -71,7 +70,7 @@ export class PlaybackQueue { if (PlaybackQueue.queues.has(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); return queue; } diff --git a/src/components/structures/InteractiveAuth.tsx b/src/components/structures/InteractiveAuth.tsx index 0c8c2a807a..01b55c1542 100644 --- a/src/components/structures/InteractiveAuth.tsx +++ b/src/components/structures/InteractiveAuth.tsx @@ -177,10 +177,6 @@ export default class InteractiveAuthComponent extends React.Component { - this.stageComponent.current?.tryContinue?.(); - }; - private authStateUpdated = (stageType: AuthType, stageState: IStageStatus): void => { const oldStage = this.state.authStage; this.setState({ diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 4c868ab15f..4967954cdd 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -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"); 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 { UPDATE_EVENT } from "../../stores/AsyncStore"; import RoomView from './RoomView'; +import type { RoomView as RoomViewType } from './RoomView'; import ToastContainer from './ToastContainer'; import MyGroups from "./MyGroups"; import UserView from "./UserView"; @@ -139,7 +140,7 @@ class LoggedInView extends React.Component { static displayName = 'LoggedInView'; protected readonly _matrixClient: MatrixClient; - protected readonly _roomView: React.RefObject; + protected readonly _roomView: React.RefObject; protected readonly _resizeContainer: React.RefObject; protected readonly resizeHandler: React.RefObject; protected layoutWatcherRef: string; diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index ebc90f51ad..426920f098 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -229,7 +229,6 @@ export default class MatrixChat extends React.PureComponent { private firstSyncPromise: IDeferred; private screenAfterLogin?: IScreen; - private pageChanging: boolean; private tokenLogin?: boolean; private accountPassword?: string; private accountPasswordTimer?: number; @@ -284,8 +283,6 @@ export default class MatrixChat extends React.PureComponent { this.prevWindowWidth = UIStore.instance.windowWidth || 1000; UIStore.instance.on(UI_EVENTS.Resize, this.handleResize); - this.pageChanging = false; - // For PersistentElement this.state.resizeNotifier.on("middlePanelResized", this.dispatchTimelineResize); diff --git a/src/components/structures/RoomDirectory.tsx b/src/components/structures/RoomDirectory.tsx index b29cc245fd..fc1fc39df9 100644 --- a/src/components/structures/RoomDirectory.tsx +++ b/src/components/structures/RoomDirectory.tsx @@ -78,7 +78,6 @@ interface IState { @replaceableComponent("structures.RoomDirectory") export default class RoomDirectory extends React.Component { - private readonly startTime: number; private unmounted = false; private nextBatch: string = null; private filterTimeout: number; diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index d69a9d2054..cbfe8d0c2e 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1681,8 +1681,8 @@ export class RoomView extends React.Component { * * We pass it down to the scroll panel. */ - private handleScrollKey = ev => { - let panel; + public handleScrollKey = ev => { + let panel: ScrollPanel | TimelinePanel; if (this.searchResultsPanel.current) { panel = this.searchResultsPanel.current; } else if (this.messagePanel) { diff --git a/src/components/views/auth/InteractiveAuthEntryComponents.tsx b/src/components/views/auth/InteractiveAuthEntryComponents.tsx index 1903fcd96e..e4b9a7422e 100644 --- a/src/components/views/auth/InteractiveAuthEntryComponents.tsx +++ b/src/components/views/auth/InteractiveAuthEntryComponents.tsx @@ -326,10 +326,6 @@ export class TermsAuthEntry extends React.Component { - this.trySubmit(); - }; - private togglePolicy(policyId: string) { const newToggles = {}; for (const policy of this.state.policies) { @@ -832,7 +828,6 @@ export interface IStageComponentProps extends IAuthEntryProps { } export interface IStageComponent extends React.ComponentClass> { - tryContinue?(): void; attemptFailed?(): void; focus?(): void; } diff --git a/src/components/views/dialogs/LogoutDialog.tsx b/src/components/views/dialogs/LogoutDialog.tsx index 11868f3820..cca6935258 100644 --- a/src/components/views/dialogs/LogoutDialog.tsx +++ b/src/components/views/dialogs/LogoutDialog.tsx @@ -1,6 +1,6 @@ /* 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"); you may not use this file except in compliance with the License. @@ -81,11 +81,6 @@ export default class LogoutDialog extends React.Component { } } - private onSettingsLinkClick = (): void => { - // close dialog - this.props.onFinished(true); - }; - private onExportE2eKeysClicked = (): void => { Modal.createTrackedDialogAsync('Export E2E Keys', '', import( diff --git a/src/components/views/settings/Notifications.tsx b/src/components/views/settings/Notifications.tsx index d86d6e7c7b..2f05b5e4dc 100644 --- a/src/components/views/settings/Notifications.tsx +++ b/src/components/views/settings/Notifications.tsx @@ -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"); you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import { VectorPushRulesDefinitions, VectorState, } from "../../../notifications"; +import type { VectorPushRuleDefinition } from "../../../notifications"; import { _t, TranslatedString } from "../../../languageHandler"; import LabelledToggleSwitch from "../elements/LabelledToggleSwitch"; import SettingsStore from "../../../settings/SettingsStore"; @@ -209,7 +210,7 @@ export default class Notifications extends React.PureComponent { for (const category of vectorCategories) { preparedNewState.vectorPushRules[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); preparedNewState.vectorPushRules[category].push({ ruleId: rule.rule_id, @@ -356,7 +357,7 @@ export default class Notifications extends React.PureComponent { } } } else { - const definition = VectorPushRulesDefinitions[rule.ruleId]; + const definition: VectorPushRuleDefinition = VectorPushRulesDefinitions[rule.ruleId]; const actions = definition.vectorStateToActions[checkedState]; if (!actions) { await cli.setPushRuleEnabled('global', rule.rule.kind, rule.rule.rule_id, false); diff --git a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx index 5b744fc0f6..df3ebe6d40 100644 --- a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx @@ -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"); you may not use this file except in compliance with the License. @@ -100,18 +100,6 @@ export default class HelpUserSettingsTab extends React.Component }); }; - 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() { const tocLinks = SdkConfig.get().terms_and_conditions_links; if (!tocLinks) return null; diff --git a/src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx b/src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx index 288c14ea7d..aa66d0203a 100644 --- a/src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/SecurityUserSettingsTab.tsx @@ -1,6 +1,5 @@ /* -Copyright 2019 New Vector Ltd -Copyright 2020 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"); you may not use this file except in compliance with the License. @@ -147,14 +146,6 @@ export default class SecurityUserSettingsTab extends React.Component { - dis.dispatch({ - action: 'view_user_info', - userId: MatrixClientPeg.get().getUserId(), - }); - this.props.closeSettingsFn(); - }; - private onUserUnignored = async (userId: string): Promise => { const { ignoredUserIds, waitingUnignored } = this.state; const currentlyIgnoredUserIds = ignoredUserIds.filter(e => !waitingUnignored.includes(e)); diff --git a/src/components/views/spaces/SpacePanel.tsx b/src/components/views/spaces/SpacePanel.tsx index a1dd62e735..70e1de55cb 100644 --- a/src/components/views/spaces/SpacePanel.tsx +++ b/src/components/views/spaces/SpacePanel.tsx @@ -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"); you may not use this file except in compliance with the License. @@ -205,7 +205,7 @@ const CreateSpaceButton = ({ }: Pick) => { // We don't need the handle as we position the menu in a constant location // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu(); + const [menuDisplayed, _handle, openMenu, closeMenu] = useContextMenu(); useEffect(() => { if (!isPanelCollapsed && menuDisplayed) { diff --git a/src/components/views/voip/CallViewForRoom.tsx b/src/components/views/voip/CallViewForRoom.tsx index e02a85a9fb..25fbf4a501 100644 --- a/src/components/views/voip/CallViewForRoom.tsx +++ b/src/components/views/voip/CallViewForRoom.tsx @@ -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"); you may not use this file except in compliance with the License. @@ -42,8 +42,6 @@ interface IState { */ @replaceableComponent("views.voip.CallViewForRoom") export default class CallViewForRoom extends React.Component { - private dispatcherRef: string; - constructor(props: IProps) { super(props); this.state = { diff --git a/src/notifications/VectorPushRulesDefinitions.ts b/src/notifications/VectorPushRulesDefinitions.ts index 4a5bcc4e59..85cefd5194 100644 --- a/src/notifications/VectorPushRulesDefinitions.ts +++ b/src/notifications/VectorPushRulesDefinitions.ts @@ -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"); 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. */ -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 { _td } from '../languageHandler'; @@ -26,32 +26,29 @@ type StateToActionsMap = { [state in VectorState]?: PushRuleAction[]; }; -interface IProps { - kind: PushRuleKind; +interface IVectorPushRuleDefinition { description: string; vectorStateToActions: StateToActionsMap; } class VectorPushRuleDefinition { - private kind: PushRuleKind; - private description: string; + public readonly description: string; public readonly vectorStateToActions: StateToActionsMap; - constructor(opts: IProps) { - this.kind = opts.kind; + constructor(opts: IVectorPushRuleDefinition) { this.description = opts.description; this.vectorStateToActions = opts.vectorStateToActions; } // Translate the rule actions and its enabled value into vector state - public ruleToVectorState(rule): VectorPushRuleDefinition { + public ruleToVectorState(rule: IAnnotatedPushRule): VectorState { let enabled = false; if (rule) { enabled = rule.enabled; } 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]; if (!vectorStateToActions) { @@ -78,6 +75,7 @@ class VectorPushRuleDefinition { return undefined; } } +export type { VectorPushRuleDefinition }; /** * The descriptions of rules managed by the Vector UI. @@ -85,7 +83,6 @@ class VectorPushRuleDefinition { export const VectorPushRulesDefinitions = { // Messages containing user's display name ".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 vectorStateToActions: { // The actions for each vector state, or null to disable the rule. [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -96,7 +93,6 @@ export const VectorPushRulesDefinitions = { // Messages containing user's username (localpart/MXID) ".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 vectorStateToActions: { // The actions for each vector state, or null to disable the rule. [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -107,7 +103,6 @@ export const VectorPushRulesDefinitions = { // Messages containing @room ".m.rule.roomnotif": new VectorPushRuleDefinition({ - kind: PushRuleKind.Override, 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. [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -118,7 +113,6 @@ export const VectorPushRulesDefinitions = { // Messages just sent to the user in a 1:1 room ".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 vectorStateToActions: { [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -129,7 +123,6 @@ export const VectorPushRulesDefinitions = { // Encrypted messages just sent to the user in a 1:1 room ".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 vectorStateToActions: { [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 // By opposition, all other room messages are from group chat rooms. ".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 vectorStateToActions: { [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 // By opposition, all other room messages are from group chat rooms. ".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 vectorStateToActions: { [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -166,7 +157,6 @@ export const VectorPushRulesDefinitions = { // Invitation for the user ".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 vectorStateToActions: { [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -177,7 +167,6 @@ export const VectorPushRulesDefinitions = { // Incoming call ".m.rule.call": new VectorPushRuleDefinition({ - kind: PushRuleKind.Underride, description: _td("Call invitation"), // passed through _t() translation in src/components/views/settings/Notifications.js vectorStateToActions: { [VectorState.On]: StandardActions.ACTION_NOTIFY, @@ -188,7 +177,6 @@ export const VectorPushRulesDefinitions = { // Notifications from bots ".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 vectorStateToActions: { // .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) ".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 vectorStateToActions: { // The actions for each vector state, or null to disable the rule. [VectorState.On]: StandardActions.ACTION_NOTIFY, diff --git a/src/stores/notifications/ListNotificationState.ts b/src/stores/notifications/ListNotificationState.ts index 4e12fbbf26..56af3be178 100644 --- a/src/stores/notifications/ListNotificationState.ts +++ b/src/stores/notifications/ListNotificationState.ts @@ -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"); 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 { NotificationColor } from "./NotificationColor"; -import { TagID } from "../room-list/models"; import { arrayDiff } from "../../utils/arrays"; import { RoomNotificationState } from "./RoomNotificationState"; import { NotificationState, NotificationStateEvents } from "./NotificationState"; @@ -28,7 +27,7 @@ export class ListNotificationState extends NotificationState { private rooms: Room[] = []; private states: { [roomId: string]: RoomNotificationState } = {}; - constructor(private byTileCount = false, private tagId: TagID, private getRoomFn: FetchRoomFn) { + constructor(private byTileCount = false, private getRoomFn: FetchRoomFn) { super(); } diff --git a/src/stores/notifications/RoomNotificationStateStore.ts b/src/stores/notifications/RoomNotificationStateStore.ts index 638b7df096..6090797384 100644 --- a/src/stores/notifications/RoomNotificationStateStore.ts +++ b/src/stores/notifications/RoomNotificationStateStore.ts @@ -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"); you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient { const getRoomFn: FetchRoomFn = (room: Room) => { return this.getRoomState(room); }; - const state = new ListNotificationState(useTileCount, tagId, getRoomFn); + const state = new ListNotificationState(useTileCount, getRoomFn); this.listMap.set(tagId, state); return state; } diff --git a/src/stores/notifications/SpaceNotificationState.ts b/src/stores/notifications/SpaceNotificationState.ts index e5acf7e949..db21e635b4 100644 --- a/src/stores/notifications/SpaceNotificationState.ts +++ b/src/stores/notifications/SpaceNotificationState.ts @@ -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"); 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 private states: { [spaceId: string]: RoomNotificationState } = {}; - constructor(private spaceId: string | symbol, private getRoomFn: FetchRoomFn) { + constructor(private getRoomFn: FetchRoomFn) { super(); } diff --git a/src/stores/room-list/RoomListStore.ts b/src/stores/room-list/RoomListStore.ts index 2142efa098..57303993fe 100644 --- a/src/stores/room-list/RoomListStore.ts +++ b/src/stores/room-list/RoomListStore.ts @@ -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"); you may not use this file except in compliance with the License. @@ -64,8 +64,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient { private algorithm = new Algorithm(); private filterConditions: IFilterCondition[] = []; private prefilterConditions: IFilterCondition[] = []; - private tagWatcher: TagWatcher; - private spaceWatcher: SpaceWatcher; private updateFn = new MarkedExecution(() => { for (const tagId of Object.keys(this.orderedLists)) { RoomNotificationStateStore.instance.getListState(tagId).setRooms(this.orderedLists[tagId]); @@ -83,10 +81,11 @@ export class RoomListStoreClass extends AsyncStoreWithClient { } private setupWatchers() { + // TODO: Maybe destroy these if this class supports destruction if (SpaceStore.spacesEnabled) { - this.spaceWatcher = new SpaceWatcher(this); + new SpaceWatcher(this); } else { - this.tagWatcher = new TagWatcher(this); + new TagWatcher(this); } } @@ -106,7 +105,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient { this.filterConditions = []; this.prefilterConditions = []; this.initialListsGenerated = false; - this.setupWatchers(); this.algorithm.off(LIST_UPDATED_EVENT, this.onAlgorithmListUpdated); this.algorithm.off(FILTER_CHANGED, this.onAlgorithmListUpdated); @@ -131,7 +129,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient { this.algorithm.on(FILTER_CHANGED, this.onAlgorithmFilterUpdated); 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. logger.log("Regenerating room lists: Startup"); await this.readAndCacheSettingsFromStore(); diff --git a/src/stores/spaces/SpaceStore.ts b/src/stores/spaces/SpaceStore.ts index 9f32816fbd..45333866ef 100644 --- a/src/stores/spaces/SpaceStore.ts +++ b/src/stores/spaces/SpaceStore.ts @@ -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"); you may not use this file except in compliance with the License. @@ -1236,7 +1236,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient { return this.notificationStateMap.get(key); } - const state = new SpaceNotificationState(key, getRoomFn); + const state = new SpaceNotificationState(getRoomFn); this.notificationStateMap.set(key, state); return state; } diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index c0ea8a7119..8dc2cbcfff 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -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"); * you may not use this file except in compliance with the License. @@ -238,10 +238,6 @@ export class StopGapWidget extends EventEmitter { return !!this.messaging; } - private get widgetId() { - return this.messaging.widget.id; - } - private onOpenModal = async (ev: CustomEvent) => { ev.preventDefault(); if (ModalWidgetStore.instance.canOpenModalWidget()) { diff --git a/tsconfig.json b/tsconfig.json index f74079696e..40fcbe4364 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "moduleResolution": "node", "target": "es2016", "noImplicitAny": false, + "noUnusedLocals": true, "sourceMap": false, "outDir": "./lib", "declaration": true,