Conform more of the codebase to strict typing (#11195)
This commit is contained in:
parent
f32b9bab99
commit
285847560b
12 changed files with 59 additions and 59 deletions
|
@ -24,6 +24,7 @@ import {
|
||||||
MatrixClient,
|
MatrixClient,
|
||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
import { MatrixError, HTTPError } from "matrix-js-sdk/src/matrix";
|
import { MatrixError, HTTPError } from "matrix-js-sdk/src/matrix";
|
||||||
|
import { IThreepid } from "matrix-js-sdk/src/@types/threepids";
|
||||||
|
|
||||||
import Modal from "./Modal";
|
import Modal from "./Modal";
|
||||||
import { _t, UserFriendlyError } from "./languageHandler";
|
import { _t, UserFriendlyError } from "./languageHandler";
|
||||||
|
@ -45,6 +46,9 @@ export type Binding = {
|
||||||
errorTitle: string;
|
errorTitle: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// IThreepid modified stripping validated_at and added_at as they aren't necessary for our UI
|
||||||
|
export type ThirdPartyIdentifier = Omit<IThreepid, "validated_at" | "added_at">;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows a user to add a third party identifier to their homeserver and,
|
* Allows a user to add a third party identifier to their homeserver and,
|
||||||
* optionally, the identity servers.
|
* optionally, the identity servers.
|
||||||
|
|
|
@ -55,7 +55,7 @@ import {
|
||||||
SlidingSync,
|
SlidingSync,
|
||||||
} from "matrix-js-sdk/src/sliding-sync";
|
} from "matrix-js-sdk/src/sliding-sync";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { IDeferred, defer, sleep } from "matrix-js-sdk/src/utils";
|
import { defer, sleep } from "matrix-js-sdk/src/utils";
|
||||||
|
|
||||||
// how long to long poll for
|
// how long to long poll for
|
||||||
const SLIDING_SYNC_TIMEOUT_MS = 20 * 1000;
|
const SLIDING_SYNC_TIMEOUT_MS = 20 * 1000;
|
||||||
|
@ -117,14 +117,10 @@ export class SlidingSyncManager {
|
||||||
public static readonly ListSearch = "search_list";
|
public static readonly ListSearch = "search_list";
|
||||||
private static readonly internalInstance = new SlidingSyncManager();
|
private static readonly internalInstance = new SlidingSyncManager();
|
||||||
|
|
||||||
public slidingSync: SlidingSync;
|
public slidingSync?: SlidingSync;
|
||||||
private client?: MatrixClient;
|
private client?: MatrixClient;
|
||||||
|
|
||||||
private configureDefer: IDeferred<void>;
|
private configureDefer = defer<void>();
|
||||||
|
|
||||||
public constructor() {
|
|
||||||
this.configureDefer = defer<void>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static get instance(): SlidingSyncManager {
|
public static get instance(): SlidingSyncManager {
|
||||||
return SlidingSyncManager.internalInstance;
|
return SlidingSyncManager.internalInstance;
|
||||||
|
@ -185,7 +181,7 @@ export class SlidingSyncManager {
|
||||||
public async ensureListRegistered(listKey: string, updateArgs: PartialSlidingSyncRequest): Promise<MSC3575List> {
|
public async ensureListRegistered(listKey: string, updateArgs: PartialSlidingSyncRequest): Promise<MSC3575List> {
|
||||||
logger.debug("ensureListRegistered:::", listKey, updateArgs);
|
logger.debug("ensureListRegistered:::", listKey, updateArgs);
|
||||||
await this.configureDefer.promise;
|
await this.configureDefer.promise;
|
||||||
let list = this.slidingSync.getListParams(listKey);
|
let list = this.slidingSync!.getListParams(listKey);
|
||||||
if (!list) {
|
if (!list) {
|
||||||
list = {
|
list = {
|
||||||
ranges: [[0, 20]],
|
ranges: [[0, 20]],
|
||||||
|
@ -224,19 +220,19 @@ export class SlidingSyncManager {
|
||||||
try {
|
try {
|
||||||
// if we only have range changes then call a different function so we don't nuke the list from before
|
// if we only have range changes then call a different function so we don't nuke the list from before
|
||||||
if (updateArgs.ranges && Object.keys(updateArgs).length === 1) {
|
if (updateArgs.ranges && Object.keys(updateArgs).length === 1) {
|
||||||
await this.slidingSync.setListRanges(listKey, updateArgs.ranges);
|
await this.slidingSync!.setListRanges(listKey, updateArgs.ranges);
|
||||||
} else {
|
} else {
|
||||||
await this.slidingSync.setList(listKey, list);
|
await this.slidingSync!.setList(listKey, list);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.debug("ensureListRegistered: update failed txn_id=", err);
|
logger.debug("ensureListRegistered: update failed txn_id=", err);
|
||||||
}
|
}
|
||||||
return this.slidingSync.getListParams(listKey)!;
|
return this.slidingSync!.getListParams(listKey)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setRoomVisible(roomId: string, visible: boolean): Promise<string> {
|
public async setRoomVisible(roomId: string, visible: boolean): Promise<string> {
|
||||||
await this.configureDefer.promise;
|
await this.configureDefer.promise;
|
||||||
const subscriptions = this.slidingSync.getRoomSubscriptions();
|
const subscriptions = this.slidingSync!.getRoomSubscriptions();
|
||||||
if (visible) {
|
if (visible) {
|
||||||
subscriptions.add(roomId);
|
subscriptions.add(roomId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,9 +249,9 @@ export class SlidingSyncManager {
|
||||||
logger.log("SlidingSync setRoomVisible:", roomId, visible, "shouldLazyLoad:", shouldLazyLoad);
|
logger.log("SlidingSync setRoomVisible:", roomId, visible, "shouldLazyLoad:", shouldLazyLoad);
|
||||||
if (shouldLazyLoad) {
|
if (shouldLazyLoad) {
|
||||||
// lazy load this room
|
// lazy load this room
|
||||||
this.slidingSync.useCustomSubscription(roomId, UNENCRYPTED_SUBSCRIPTION_NAME);
|
this.slidingSync!.useCustomSubscription(roomId, UNENCRYPTED_SUBSCRIPTION_NAME);
|
||||||
}
|
}
|
||||||
const p = this.slidingSync.modifyRoomSubscriptions(subscriptions);
|
const p = this.slidingSync!.modifyRoomSubscriptions(subscriptions);
|
||||||
if (room) {
|
if (room) {
|
||||||
return roomId; // we have data already for this room, show immediately e.g it's in a list
|
return roomId; // we have data already for this room, show immediately e.g it's in a list
|
||||||
}
|
}
|
||||||
|
@ -287,7 +283,7 @@ export class SlidingSyncManager {
|
||||||
[startIndex, endIndex],
|
[startIndex, endIndex],
|
||||||
];
|
];
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
await this.slidingSync.setList(SlidingSyncManager.ListSearch, {
|
await this.slidingSync!.setList(SlidingSyncManager.ListSearch, {
|
||||||
// e.g [0,19] [20,39] then [0,19] [40,59]. We keep [0,20] constantly to ensure
|
// e.g [0,19] [20,39] then [0,19] [40,59]. We keep [0,20] constantly to ensure
|
||||||
// any changes to the list whilst spidering are caught.
|
// any changes to the list whilst spidering are caught.
|
||||||
ranges: ranges,
|
ranges: ranges,
|
||||||
|
@ -313,7 +309,7 @@ export class SlidingSyncManager {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await this.slidingSync.setListRanges(SlidingSyncManager.ListSearch, ranges);
|
await this.slidingSync!.setListRanges(SlidingSyncManager.ListSearch, ranges);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// do nothing, as we reject only when we get interrupted but that's fine as the next
|
// do nothing, as we reject only when we get interrupted but that's fine as the next
|
||||||
|
@ -322,7 +318,7 @@ export class SlidingSyncManager {
|
||||||
// gradually request more over time, even on errors.
|
// gradually request more over time, even on errors.
|
||||||
await sleep(gapBetweenRequestsMs);
|
await sleep(gapBetweenRequestsMs);
|
||||||
}
|
}
|
||||||
const listData = this.slidingSync.getListData(SlidingSyncManager.ListSearch)!;
|
const listData = this.slidingSync!.getListData(SlidingSyncManager.ListSearch)!;
|
||||||
hasMore = endIndex + 1 < listData.joinedCount;
|
hasMore = endIndex + 1 < listData.joinedCount;
|
||||||
startIndex += batchSize;
|
startIndex += batchSize;
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
|
|
|
@ -103,7 +103,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||||
hasCancel: true,
|
hasCancel: true,
|
||||||
forceReset: false,
|
forceReset: false,
|
||||||
};
|
};
|
||||||
private recoveryKey: IRecoveryKey;
|
private recoveryKey?: IRecoveryKey;
|
||||||
private backupKey?: Uint8Array;
|
private backupKey?: Uint8Array;
|
||||||
private recoveryKeyNode = createRef<HTMLElement>();
|
private recoveryKeyNode = createRef<HTMLElement>();
|
||||||
private passphraseField = createRef<Field>();
|
private passphraseField = createRef<Field>();
|
||||||
|
@ -270,6 +270,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||||
};
|
};
|
||||||
|
|
||||||
private onDownloadClick = (): void => {
|
private onDownloadClick = (): void => {
|
||||||
|
if (!this.recoveryKey) return;
|
||||||
const blob = new Blob([this.recoveryKey.encodedPrivateKey!], {
|
const blob = new Blob([this.recoveryKey.encodedPrivateKey!], {
|
||||||
type: "text/plain;charset=us-ascii",
|
type: "text/plain;charset=us-ascii",
|
||||||
});
|
});
|
||||||
|
@ -341,7 +342,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||||
if (forceReset) {
|
if (forceReset) {
|
||||||
logger.log("Forcing secret storage reset");
|
logger.log("Forcing secret storage reset");
|
||||||
await cli.bootstrapSecretStorage({
|
await cli.bootstrapSecretStorage({
|
||||||
createSecretStorageKey: async () => this.recoveryKey,
|
createSecretStorageKey: async () => this.recoveryKey!,
|
||||||
setupNewKeyBackup: true,
|
setupNewKeyBackup: true,
|
||||||
setupNewSecretStorage: true,
|
setupNewSecretStorage: true,
|
||||||
});
|
});
|
||||||
|
@ -357,7 +358,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||||
authUploadDeviceSigningKeys: this.doBootstrapUIAuth,
|
authUploadDeviceSigningKeys: this.doBootstrapUIAuth,
|
||||||
});
|
});
|
||||||
await cli.bootstrapSecretStorage({
|
await cli.bootstrapSecretStorage({
|
||||||
createSecretStorageKey: async () => this.recoveryKey,
|
createSecretStorageKey: async () => this.recoveryKey!,
|
||||||
keyBackupInfo: this.state.backupInfo!,
|
keyBackupInfo: this.state.backupInfo!,
|
||||||
setupNewKeyBackup: !this.state.backupInfo,
|
setupNewKeyBackup: !this.state.backupInfo,
|
||||||
getKeyBackupPassphrase: async (): Promise<Uint8Array> => {
|
getKeyBackupPassphrase: async (): Promise<Uint8Array> => {
|
||||||
|
@ -762,7 +763,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent<IProp
|
||||||
<div className="mx_CreateSecretStorageDialog_primaryContainer mx_CreateSecretStorageDialog_recoveryKeyPrimarycontainer">
|
<div className="mx_CreateSecretStorageDialog_primaryContainer mx_CreateSecretStorageDialog_recoveryKeyPrimarycontainer">
|
||||||
<div className="mx_CreateSecretStorageDialog_recoveryKeyContainer">
|
<div className="mx_CreateSecretStorageDialog_recoveryKeyContainer">
|
||||||
<div className="mx_CreateSecretStorageDialog_recoveryKey">
|
<div className="mx_CreateSecretStorageDialog_recoveryKey">
|
||||||
<code ref={this.recoveryKeyNode}>{this.recoveryKey.encodedPrivateKey}</code>
|
<code ref={this.recoveryKeyNode}>{this.recoveryKey?.encodedPrivateKey}</code>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_CreateSecretStorageDialog_recoveryKeyButtons">
|
<div className="mx_CreateSecretStorageDialog_recoveryKeyButtons">
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
|
|
|
@ -566,7 +566,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
let isAlphabetical = RoomListStore.instance.getTagSorting(this.props.tagId) === SortAlgorithm.Alphabetic;
|
let isAlphabetical = RoomListStore.instance.getTagSorting(this.props.tagId) === SortAlgorithm.Alphabetic;
|
||||||
let isUnreadFirst = RoomListStore.instance.getListOrder(this.props.tagId) === ListAlgorithm.Importance;
|
let isUnreadFirst = RoomListStore.instance.getListOrder(this.props.tagId) === ListAlgorithm.Importance;
|
||||||
if (this.slidingSyncMode) {
|
if (this.slidingSyncMode) {
|
||||||
const slidingList = SlidingSyncManager.instance.slidingSync.getListParams(this.props.tagId);
|
const slidingList = SlidingSyncManager.instance.slidingSync?.getListParams(this.props.tagId);
|
||||||
isAlphabetical = (slidingList?.sort || [])[0] === "by_name";
|
isAlphabetical = (slidingList?.sort || [])[0] === "by_name";
|
||||||
isUnreadFirst = (slidingList?.sort || [])[0] === "by_notification_level";
|
isUnreadFirst = (slidingList?.sort || [])[0] === "by_notification_level";
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
import { ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||||
import Field from "../../elements/Field";
|
import Field from "../../elements/Field";
|
||||||
import AccessibleButton, { ButtonEvent } from "../../elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent } from "../../elements/AccessibleButton";
|
||||||
import * as Email from "../../../../email";
|
import * as Email from "../../../../email";
|
||||||
import AddThreepid from "../../../../AddThreepid";
|
import AddThreepid, { ThirdPartyIdentifier } from "../../../../AddThreepid";
|
||||||
import Modal from "../../../../Modal";
|
import Modal from "../../../../Modal";
|
||||||
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ that is available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface IExistingEmailAddressProps {
|
interface IExistingEmailAddressProps {
|
||||||
email: IThreepid;
|
email: ThirdPartyIdentifier;
|
||||||
onRemoved: (emails: IThreepid) => void;
|
onRemoved: (emails: ThirdPartyIdentifier) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IExistingEmailAddressState {
|
interface IExistingEmailAddressState {
|
||||||
|
@ -130,8 +130,8 @@ export class ExistingEmailAddress extends React.Component<IExistingEmailAddressP
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
emails: IThreepid[];
|
emails: ThirdPartyIdentifier[];
|
||||||
onEmailsChange: (emails: Partial<IThreepid>[]) => void;
|
onEmailsChange: (emails: ThirdPartyIdentifier[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
|
@ -153,7 +153,7 @@ export default class EmailAddresses extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRemoved = (address: IThreepid): void => {
|
private onRemoved = (address: ThirdPartyIdentifier): void => {
|
||||||
const emails = this.props.emails.filter((e) => e !== address);
|
const emails = this.props.emails.filter((e) => e !== address);
|
||||||
this.props.onEmailsChange(emails);
|
this.props.onEmailsChange(emails);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,14 +16,14 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
import { ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
import { _t, UserFriendlyError } from "../../../../languageHandler";
|
import { _t, UserFriendlyError } from "../../../../languageHandler";
|
||||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||||
import Field from "../../elements/Field";
|
import Field from "../../elements/Field";
|
||||||
import AccessibleButton, { ButtonEvent } from "../../elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent } from "../../elements/AccessibleButton";
|
||||||
import AddThreepid from "../../../../AddThreepid";
|
import AddThreepid, { ThirdPartyIdentifier } from "../../../../AddThreepid";
|
||||||
import CountryDropdown from "../../auth/CountryDropdown";
|
import CountryDropdown from "../../auth/CountryDropdown";
|
||||||
import Modal from "../../../../Modal";
|
import Modal from "../../../../Modal";
|
||||||
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
||||||
|
@ -37,8 +37,8 @@ This is a copy/paste of EmailAddresses, mostly.
|
||||||
// TODO: Combine EmailAddresses and PhoneNumbers to be 3pid agnostic
|
// TODO: Combine EmailAddresses and PhoneNumbers to be 3pid agnostic
|
||||||
|
|
||||||
interface IExistingPhoneNumberProps {
|
interface IExistingPhoneNumberProps {
|
||||||
msisdn: IThreepid;
|
msisdn: ThirdPartyIdentifier;
|
||||||
onRemoved: (phoneNumber: IThreepid) => void;
|
onRemoved: (phoneNumber: ThirdPartyIdentifier) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IExistingPhoneNumberState {
|
interface IExistingPhoneNumberState {
|
||||||
|
@ -125,8 +125,8 @@ export class ExistingPhoneNumber extends React.Component<IExistingPhoneNumberPro
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
msisdns: IThreepid[];
|
msisdns: ThirdPartyIdentifier[];
|
||||||
onMsisdnsChange: (phoneNumbers: Partial<IThreepid>[]) => void;
|
onMsisdnsChange: (phoneNumbers: ThirdPartyIdentifier[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
|
@ -156,7 +156,7 @@ export default class PhoneNumbers extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRemoved = (address: IThreepid): void => {
|
private onRemoved = (address: ThirdPartyIdentifier): void => {
|
||||||
const msisdns = this.props.msisdns.filter((e) => e !== address);
|
const msisdns = this.props.msisdns.filter((e) => e !== address);
|
||||||
this.props.onMsisdnsChange(msisdns);
|
this.props.onMsisdnsChange(msisdns);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,14 +16,13 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IThreepid } from "matrix-js-sdk/src/@types/threepids";
|
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import { _t, UserFriendlyError } from "../../../../languageHandler";
|
import { _t, UserFriendlyError } from "../../../../languageHandler";
|
||||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||||
import Modal from "../../../../Modal";
|
import Modal from "../../../../Modal";
|
||||||
import AddThreepid, { Binding } from "../../../../AddThreepid";
|
import AddThreepid, { Binding, ThirdPartyIdentifier } from "../../../../AddThreepid";
|
||||||
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
||||||
import SettingsSubsection from "../shared/SettingsSubsection";
|
import SettingsSubsection from "../shared/SettingsSubsection";
|
||||||
import InlineSpinner from "../../elements/InlineSpinner";
|
import InlineSpinner from "../../elements/InlineSpinner";
|
||||||
|
@ -46,7 +45,7 @@ TODO: Reduce all the copying between account vs. discovery components.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface IEmailAddressProps {
|
interface IEmailAddressProps {
|
||||||
email: IThreepid;
|
email: ThirdPartyIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IEmailAddressState {
|
interface IEmailAddressState {
|
||||||
|
@ -259,7 +258,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
interface IProps {
|
interface IProps {
|
||||||
emails: IThreepid[];
|
emails: ThirdPartyIdentifier[];
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,13 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IThreepid } from "matrix-js-sdk/src/@types/threepids";
|
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import { _t, UserFriendlyError } from "../../../../languageHandler";
|
import { _t, UserFriendlyError } from "../../../../languageHandler";
|
||||||
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../../MatrixClientPeg";
|
||||||
import Modal from "../../../../Modal";
|
import Modal from "../../../../Modal";
|
||||||
import AddThreepid, { Binding } from "../../../../AddThreepid";
|
import AddThreepid, { Binding, ThirdPartyIdentifier } from "../../../../AddThreepid";
|
||||||
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
import ErrorDialog, { extractErrorMessageFromError } from "../../dialogs/ErrorDialog";
|
||||||
import Field from "../../elements/Field";
|
import Field from "../../elements/Field";
|
||||||
import SettingsSubsection from "../shared/SettingsSubsection";
|
import SettingsSubsection from "../shared/SettingsSubsection";
|
||||||
|
@ -38,7 +37,7 @@ This is a copy/paste of EmailAddresses, mostly.
|
||||||
// TODO: Combine EmailAddresses and PhoneNumbers to be 3pid agnostic
|
// TODO: Combine EmailAddresses and PhoneNumbers to be 3pid agnostic
|
||||||
|
|
||||||
interface IPhoneNumberProps {
|
interface IPhoneNumberProps {
|
||||||
msisdn: IThreepid;
|
msisdn: ThirdPartyIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IPhoneNumberState {
|
interface IPhoneNumberState {
|
||||||
|
@ -274,7 +273,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
msisdns: IThreepid[];
|
msisdns: ThirdPartyIdentifier[];
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ import { SettingsSubsectionHeading } from "../../shared/SettingsSubsectionHeadin
|
||||||
import Heading from "../../../typography/Heading";
|
import Heading from "../../../typography/Heading";
|
||||||
import InlineSpinner from "../../../elements/InlineSpinner";
|
import InlineSpinner from "../../../elements/InlineSpinner";
|
||||||
import MatrixClientContext from "../../../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../../../contexts/MatrixClientContext";
|
||||||
|
import { ThirdPartyIdentifier } from "../../../../../AddThreepid";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
closeSettingsFn: () => void;
|
closeSettingsFn: () => void;
|
||||||
|
@ -87,8 +88,8 @@ interface IState {
|
||||||
agreedUrls: string[];
|
agreedUrls: string[];
|
||||||
resolve: (values: string[]) => void;
|
resolve: (values: string[]) => void;
|
||||||
};
|
};
|
||||||
emails: IThreepid[];
|
emails: ThirdPartyIdentifier[];
|
||||||
msisdns: IThreepid[];
|
msisdns: ThirdPartyIdentifier[];
|
||||||
loading3pids: boolean; // whether or not the emails and msisdns have been loaded
|
loading3pids: boolean; // whether or not the emails and msisdns have been loaded
|
||||||
canChangePassword: boolean;
|
canChangePassword: boolean;
|
||||||
idServerName?: string;
|
idServerName?: string;
|
||||||
|
@ -156,11 +157,11 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private onEmailsChange = (emails: IThreepid[]): void => {
|
private onEmailsChange = (emails: ThirdPartyIdentifier[]): void => {
|
||||||
this.setState({ emails });
|
this.setState({ emails });
|
||||||
};
|
};
|
||||||
|
|
||||||
private onMsisdnsChange = (msisdns: IThreepid[]): void => {
|
private onMsisdnsChange = (msisdns: ThirdPartyIdentifier[]): void => {
|
||||||
this.setState({ msisdns });
|
this.setState({ msisdns });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ export const useSlidingSyncRoomSearch = (): {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const rooms: Room[] = [];
|
const rooms: Room[] = [];
|
||||||
const { roomIndexToRoomId } = SlidingSyncManager.instance.slidingSync.getListData(
|
const { roomIndexToRoomId } = SlidingSyncManager.instance.slidingSync!.getListData(
|
||||||
SlidingSyncManager.ListSearch,
|
SlidingSyncManager.ListSearch,
|
||||||
)!;
|
)!;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
|
@ -164,7 +164,7 @@ export class SlidingRoomListStoreClass extends AsyncStoreWithClient<IState> impl
|
||||||
// check all lists for each tag we know about and see if the room is there
|
// check all lists for each tag we know about and see if the room is there
|
||||||
const tags: TagID[] = [];
|
const tags: TagID[] = [];
|
||||||
for (const tagId in this.tagIdToSortAlgo) {
|
for (const tagId in this.tagIdToSortAlgo) {
|
||||||
const listData = this.context.slidingSyncManager.slidingSync.getListData(tagId);
|
const listData = this.context.slidingSyncManager.slidingSync?.getListData(tagId);
|
||||||
if (!listData) {
|
if (!listData) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ export class SlidingRoomListStoreClass extends AsyncStoreWithClient<IState> impl
|
||||||
if (room) {
|
if (room) {
|
||||||
// resort it based on the slidingSync view of the list. This may cause this old sticky
|
// resort it based on the slidingSync view of the list. This may cause this old sticky
|
||||||
// room to cease to exist.
|
// room to cease to exist.
|
||||||
const listData = this.context.slidingSyncManager.slidingSync.getListData(tagId);
|
const listData = this.context.slidingSyncManager.slidingSync?.getListData(tagId);
|
||||||
if (!listData) {
|
if (!listData) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ export class SlidingRoomListStoreClass extends AsyncStoreWithClient<IState> impl
|
||||||
protected async onReady(): Promise<any> {
|
protected async onReady(): Promise<any> {
|
||||||
logger.info("SlidingRoomListStore.onReady");
|
logger.info("SlidingRoomListStore.onReady");
|
||||||
// permanent listeners: never get destroyed. Could be an issue if we want to test this in isolation.
|
// permanent listeners: never get destroyed. Could be an issue if we want to test this in isolation.
|
||||||
this.context.slidingSyncManager.slidingSync.on(SlidingSyncEvent.List, this.onSlidingSyncListUpdate.bind(this));
|
this.context.slidingSyncManager.slidingSync!.on(SlidingSyncEvent.List, this.onSlidingSyncListUpdate.bind(this));
|
||||||
this.context.roomViewStore.addListener(UPDATE_EVENT, this.onRoomViewStoreUpdated.bind(this));
|
this.context.roomViewStore.addListener(UPDATE_EVENT, this.onRoomViewStoreUpdated.bind(this));
|
||||||
this.context.spaceStore.on(UPDATE_SELECTED_SPACE, this.onSelectedSpaceUpdated.bind(this));
|
this.context.spaceStore.on(UPDATE_SELECTED_SPACE, this.onSelectedSpaceUpdated.bind(this));
|
||||||
if (this.context.spaceStore.activeSpace) {
|
if (this.context.spaceStore.activeSpace) {
|
||||||
|
|
|
@ -194,7 +194,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
mocked(context._SlidingSyncManager!.slidingSync.getListData).mockImplementation((key: string) => {
|
mocked(context._SlidingSyncManager!.slidingSync!.getListData).mockImplementation((key: string) => {
|
||||||
return keyToListData[key] || null;
|
return keyToListData[key] || null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
const p = untilEmission(store, LISTS_UPDATE_EVENT);
|
const p = untilEmission(store, LISTS_UPDATE_EVENT);
|
||||||
context.slidingSyncManager.slidingSync.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
context.slidingSyncManager.slidingSync!.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
||||||
await p;
|
await p;
|
||||||
expect(store.getCount(tagId)).toEqual(joinCount);
|
expect(store.getCount(tagId)).toEqual(joinCount);
|
||||||
expect(store.orderedLists[tagId]).toEqual(rooms);
|
expect(store.orderedLists[tagId]).toEqual(rooms);
|
||||||
|
@ -271,7 +271,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
mocked(context._SlidingSyncManager!.slidingSync.getListData).mockImplementation((key: string) => {
|
mocked(context._SlidingSyncManager!.slidingSync!.getListData).mockImplementation((key: string) => {
|
||||||
if (key !== tagId) {
|
if (key !== tagId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
let p = untilEmission(store, LISTS_UPDATE_EVENT);
|
let p = untilEmission(store, LISTS_UPDATE_EVENT);
|
||||||
context.slidingSyncManager.slidingSync.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
context.slidingSyncManager.slidingSync!.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
||||||
await p;
|
await p;
|
||||||
expect(store.orderedLists[tagId]).toEqual([roomA, roomB, roomC]);
|
expect(store.orderedLists[tagId]).toEqual([roomA, roomB, roomC]);
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
roomIndexToRoomId[1] = roomIdA;
|
roomIndexToRoomId[1] = roomIdA;
|
||||||
roomIndexToRoomId[2] = roomIdB;
|
roomIndexToRoomId[2] = roomIdB;
|
||||||
p = untilEmission(store, LISTS_UPDATE_EVENT);
|
p = untilEmission(store, LISTS_UPDATE_EVENT);
|
||||||
context.slidingSyncManager.slidingSync.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
context.slidingSyncManager.slidingSync!.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
||||||
await p;
|
await p;
|
||||||
|
|
||||||
// check that B didn't move and that A was put below B
|
// check that B didn't move and that A was put below B
|
||||||
|
@ -332,7 +332,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
mocked(context._SlidingSyncManager!.slidingSync.getListData).mockImplementation((key: string) => {
|
mocked(context._SlidingSyncManager!.slidingSync!.getListData).mockImplementation((key: string) => {
|
||||||
if (key !== tagId) {
|
if (key !== tagId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ describe("SlidingRoomListStore", () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const p = untilEmission(store, LISTS_UPDATE_EVENT);
|
const p = untilEmission(store, LISTS_UPDATE_EVENT);
|
||||||
context.slidingSyncManager.slidingSync.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
context.slidingSyncManager.slidingSync!.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
||||||
await p;
|
await p;
|
||||||
expect(store.orderedLists[tagId]).toEqual([roomA, roomC]);
|
expect(store.orderedLists[tagId]).toEqual([roomA, roomC]);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue