From d90321d8133bc71be3b316922bdd0386176e5a67 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Tue, 10 Aug 2021 11:03:03 +0100
Subject: [PATCH] Iterate PR, merge types with @types/PushRules

---
 src/CallHandler.tsx                              |  4 ++--
 src/components/structures/InteractiveAuth.tsx    | 16 ++++++++--------
 .../auth/InteractiveAuthEntryComponents.tsx      |  2 +-
 .../controllers/NotificationControllers.ts       |  5 +++--
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx
index 41571666c3..f2142f56f4 100644
--- a/src/CallHandler.tsx
+++ b/src/CallHandler.tsx
@@ -86,7 +86,7 @@ import { randomUppercaseString, randomLowercaseString } from "matrix-js-sdk/src/
 import EventEmitter from 'events';
 import SdkConfig from './SdkConfig';
 import { ensureDMExists, findDMForUser } from './createRoom';
-import { IPushRule, RuleId, TweakName, Tweaks } from "matrix-js-sdk/src/@types/PushRules";
+import { RuleId, TweakName, Tweaks } from "matrix-js-sdk/src/@types/PushRules";
 import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor';
 import { WidgetLayoutStore, Container } from './stores/widgets/WidgetLayoutStore';
 import { getIncomingCallToastKey } from './toasts/IncomingCallToast';
@@ -484,7 +484,7 @@ export default class CallHandler extends EventEmitter {
             switch (newState) {
                 case CallState.Ringing: {
                     const incomingCallPushRule = (
-                        new PushProcessor(MatrixClientPeg.get()).getPushRuleById(RuleId.IncomingCall) as IPushRule
+                        new PushProcessor(MatrixClientPeg.get()).getPushRuleById(RuleId.IncomingCall)
                     );
                     const pushRuleEnabled = incomingCallPushRule?.enabled;
                     const tweakSetToRing = incomingCallPushRule?.actions.some((action: Tweaks) => (
diff --git a/src/components/structures/InteractiveAuth.tsx b/src/components/structures/InteractiveAuth.tsx
index 017e34184f..cea756adc0 100644
--- a/src/components/structures/InteractiveAuth.tsx
+++ b/src/components/structures/InteractiveAuth.tsx
@@ -35,7 +35,7 @@ interface IProps {
     // matrix client to use for UI auth requests
     matrixClient: MatrixClient;
     // response from initial request. If not supplied, will do a request on mount.
-    authData: IAuthData;
+    authData?: IAuthData;
     // Inputs provided by the user to the auth process
     // and used by various stages. As passed to js-sdk
     // interactive-auth
@@ -72,11 +72,11 @@ interface IProps {
         extra?: { emailSid?: string, clientSecret?: string },
     ): void;
     // As js-sdk interactive-auth
-    requestEmailToken?(email: string, secret: string, attempt: number, session: string): Promise<{ sid: string }>,
+    requestEmailToken?(email: string, secret: string, attempt: number, session: string): Promise<{ sid: string }>;
     // Called when the stage changes, or the stage's phase changes. First
     // argument is the stage, second is the phase. Some stages do not have
     // phases and will be counted as 0 (numeric).
-    onStagePhaseChange?(stage: string, phase: string | number): void,
+    onStagePhaseChange?(stage: string, phase: string | number): void;
 }
 
 interface IState {
@@ -91,7 +91,7 @@ interface IState {
 @replaceableComponent("structures.InteractiveAuthComponent")
 export default class InteractiveAuthComponent extends React.Component<IProps, IState> {
     private readonly authLogic: InteractiveAuth;
-    private readonly _intervalId: NodeJS.Timeout = null;
+    private readonly intervalId: number = null;
     private readonly stageComponent = createRef<IStageComponent>();
 
     private unmounted = false;
@@ -121,14 +121,14 @@ export default class InteractiveAuthComponent extends React.Component<IProps, IS
         });
 
         if (this.props.poll) {
-            this._intervalId = setInterval(() => {
+            this.intervalId = setInterval(() => {
                 this.authLogic.poll();
             }, 2000);
         }
     }
 
     // TODO: [REACT-WARNING] Replace component with real class, use constructor for refs
-    UNSAFE_componentWillMount() { // eslint-disable-line camelcase
+    UNSAFE_componentWillMount() { // eslint-disable-line @typescript-eslint/naming-convention, camelcase
         this.authLogic.attemptAuth().then((result) => {
             const extra = {
                 emailSid: this.authLogic.getEmailSid(),
@@ -152,8 +152,8 @@ export default class InteractiveAuthComponent extends React.Component<IProps, IS
     componentWillUnmount() {
         this.unmounted = true;
 
-        if (this._intervalId !== null) {
-            clearInterval(this._intervalId);
+        if (this.intervalId !== null) {
+            clearInterval(this.intervalId);
         }
     }
 
diff --git a/src/components/views/auth/InteractiveAuthEntryComponents.tsx b/src/components/views/auth/InteractiveAuthEntryComponents.tsx
index 0331a4d5b4..423738acb8 100644
--- a/src/components/views/auth/InteractiveAuthEntryComponents.tsx
+++ b/src/components/views/auth/InteractiveAuthEntryComponents.tsx
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-import React, { ChangeEvent, ComponentClass, createRef, FormEvent, MouseEvent, RefObject } from 'react';
+import React, { ChangeEvent, createRef, FormEvent, MouseEvent } from 'react';
 import classNames from 'classnames';
 import { MatrixClient } from "matrix-js-sdk/src/client";
 import { AuthType, IAuthDict, IInputs, IStageStatus } from 'matrix-js-sdk/src/interactive-auth';
diff --git a/src/settings/controllers/NotificationControllers.ts b/src/settings/controllers/NotificationControllers.ts
index 1201d50317..09e4e1dd1a 100644
--- a/src/settings/controllers/NotificationControllers.ts
+++ b/src/settings/controllers/NotificationControllers.ts
@@ -20,7 +20,8 @@ import { MatrixClientPeg } from '../../MatrixClientPeg';
 import { SettingLevel } from "../SettingLevel";
 
 // XXX: This feels wrong.
-import { Action, PushProcessor } from "matrix-js-sdk/src/pushprocessor";
+import { PushProcessor } from "matrix-js-sdk/src/pushprocessor";
+import { PushRuleActionName } from "matrix-js-sdk/src/@types/PushRules";
 
 // .m.rule.master being enabled means all events match that push rule
 // default action on this rule is dont_notify, but it could be something else
@@ -35,7 +36,7 @@ export function isPushNotifyDisabled(): boolean {
     }
 
     // If the rule is enabled then check it does not notify on everything
-    return masterRule.enabled && !masterRule.actions.includes(Action.Notify);
+    return masterRule.enabled && !masterRule.actions.includes(PushRuleActionName.Notify);
 }
 
 function getNotifier(): any { // TODO: [TS] Formal type that doesn't cause a cyclical reference.