mirror of https://github.com/vector-im/riot-web
Improve typing (#7349)
parent
b2548f05a8
commit
7033f8696a
|
@ -163,6 +163,16 @@ declare global {
|
||||||
|
|
||||||
interface HTMLAudioElement {
|
interface HTMLAudioElement {
|
||||||
type?: string;
|
type?: string;
|
||||||
|
// sinkId & setSinkId are experimental and typescript doesn't know about them
|
||||||
|
sinkId: string;
|
||||||
|
setSinkId(outputId: string): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HTMLVideoElement {
|
||||||
|
type?: string;
|
||||||
|
// sinkId & setSinkId are experimental and typescript doesn't know about them
|
||||||
|
sinkId: string;
|
||||||
|
setSinkId(outputId: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface HTMLStyleElement {
|
interface HTMLStyleElement {
|
||||||
|
|
|
@ -94,9 +94,9 @@ export class DecryptionFailureTracker {
|
||||||
// localStorage.setItem('mx-decryption-failure-event-id-hashes', JSON.stringify(this.trackedEventHashMap));
|
// localStorage.setItem('mx-decryption-failure-event-id-hashes', JSON.stringify(this.trackedEventHashMap));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public eventDecrypted(e: MatrixEvent, err: MatrixError | Error): void {
|
public eventDecrypted(e: MatrixEvent, err: MatrixError): void {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.addDecryptionFailure(new DecryptionFailure(e.getId(), err.code));
|
this.addDecryptionFailure(new DecryptionFailure(e.getId(), err.errcode));
|
||||||
} else {
|
} else {
|
||||||
// Could be an event in the failures, remove it
|
// Could be an event in the failures, remove it
|
||||||
this.removeDecryptionFailuresForEvent(e);
|
this.removeDecryptionFailuresForEvent(e);
|
||||||
|
|
|
@ -15,7 +15,8 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { ComponentType, createRef } from 'react';
|
import React, { ComponentType, createRef } from 'react';
|
||||||
import { createClient } from "matrix-js-sdk/src/matrix";
|
import { createClient } from 'matrix-js-sdk/src/matrix';
|
||||||
|
import { MatrixError } from 'matrix-js-sdk/src/http-api';
|
||||||
import { InvalidStoreError } from "matrix-js-sdk/src/errors";
|
import { InvalidStoreError } from "matrix-js-sdk/src/errors";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import { Error as ErrorEvent } from "matrix-analytics-events/types/typescript/Error";
|
import { Error as ErrorEvent } from "matrix-analytics-events/types/typescript/Error";
|
||||||
|
@ -233,7 +234,7 @@ interface IState {
|
||||||
// When showing Modal dialogs we need to set aria-hidden on the root app element
|
// When showing Modal dialogs we need to set aria-hidden on the root app element
|
||||||
// and disable it when there are no dialogs
|
// and disable it when there are no dialogs
|
||||||
hideToSRUsers: boolean;
|
hideToSRUsers: boolean;
|
||||||
syncError?: Error;
|
syncError?: MatrixError;
|
||||||
resizeNotifier: ResizeNotifier;
|
resizeNotifier: ResizeNotifier;
|
||||||
serverConfig?: ValidatedServerConfig;
|
serverConfig?: ValidatedServerConfig;
|
||||||
ready: boolean;
|
ready: boolean;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import { EventType } from 'matrix-js-sdk/src/@types/event';
|
||||||
import { RoomState } from 'matrix-js-sdk/src/models/room-state';
|
import { RoomState } from 'matrix-js-sdk/src/models/room-state';
|
||||||
import { CallState, CallType, MatrixCall } from "matrix-js-sdk/src/webrtc/call";
|
import { CallState, CallType, MatrixCall } from "matrix-js-sdk/src/webrtc/call";
|
||||||
import { throttle } from "lodash";
|
import { throttle } from "lodash";
|
||||||
|
import { MatrixError } from 'matrix-js-sdk/src/http-api';
|
||||||
|
|
||||||
import shouldHideEvent from '../../shouldHideEvent';
|
import shouldHideEvent from '../../shouldHideEvent';
|
||||||
import { _t } from '../../languageHandler';
|
import { _t } from '../../languageHandler';
|
||||||
|
@ -164,7 +165,7 @@ export interface IRoomState {
|
||||||
// error object, as from the matrix client/server API
|
// error object, as from the matrix client/server API
|
||||||
// If we failed to load information about the room,
|
// If we failed to load information about the room,
|
||||||
// store the error here.
|
// store the error here.
|
||||||
roomLoadError?: Error;
|
roomLoadError?: MatrixError;
|
||||||
// Have we sent a request to join the room that we're waiting to complete?
|
// Have we sent a request to join the room that we're waiting to complete?
|
||||||
joining: boolean;
|
joining: boolean;
|
||||||
// this is true if we are fully scrolled-down, and are looking at
|
// this is true if we are fully scrolled-down, and are looking at
|
||||||
|
|
|
@ -454,7 +454,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
|
||||||
let errorText: ReactNode = _t("There was a problem communicating with the homeserver, " +
|
let errorText: ReactNode = _t("There was a problem communicating with the homeserver, " +
|
||||||
"please try again later.") + (errCode ? " (" + errCode + ")" : "");
|
"please try again later.") + (errCode ? " (" + errCode + ")" : "");
|
||||||
|
|
||||||
if (err.cors === 'rejected') {
|
if (err["cors"] === 'rejected') { // browser-request specific error field
|
||||||
if (window.location.protocol === 'https:' &&
|
if (window.location.protocol === 'https:' &&
|
||||||
(this.props.serverConfig.hsUrl.startsWith("http:") ||
|
(this.props.serverConfig.hsUrl.startsWith("http:") ||
|
||||||
!this.props.serverConfig.hsUrl.startsWith("http"))
|
!this.props.serverConfig.hsUrl.startsWith("http"))
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import * as utils from "matrix-js-sdk/src/utils";
|
import * as utils from "matrix-js-sdk/src/utils";
|
||||||
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
import { Method } from "matrix-js-sdk/src/http-api";
|
||||||
|
|
||||||
import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
|
import { AsyncStoreWithClient } from "./AsyncStoreWithClient";
|
||||||
import defaultDispatcher from "../dispatcher/dispatcher";
|
import defaultDispatcher from "../dispatcher/dispatcher";
|
||||||
|
@ -131,7 +132,7 @@ export class CommunityPrototypeStore extends AsyncStoreWithClient<IState> {
|
||||||
try {
|
try {
|
||||||
const path = utils.encodeUri("/rooms/$roomId/group_info", { $roomId: room.roomId });
|
const path = utils.encodeUri("/rooms/$roomId/group_info", { $roomId: room.roomId });
|
||||||
const profile = await this.matrixClient.http.authedRequest(
|
const profile = await this.matrixClient.http.authedRequest(
|
||||||
undefined, "GET", path,
|
undefined, Method.Get, path,
|
||||||
undefined, undefined,
|
undefined, undefined,
|
||||||
{ prefix: "/_matrix/client/unstable/im.vector.custom" });
|
{ prefix: "/_matrix/client/unstable/im.vector.custom" });
|
||||||
// we use global account data because per-room account data on invites is unreliable
|
// we use global account data because per-room account data on invites is unreliable
|
||||||
|
|
|
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React, { ReactNode } from "react";
|
||||||
import { Store } from 'flux/utils';
|
import { Store } from 'flux/utils';
|
||||||
import { MatrixError } from "matrix-js-sdk/src/http-api";
|
import { MatrixError } from "matrix-js-sdk/src/http-api";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
@ -317,8 +317,8 @@ class RoomViewStore extends Store<ActionPayload> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public showJoinRoomError(err: Error | MatrixError, roomId: string) {
|
public showJoinRoomError(err: MatrixError, roomId: string) {
|
||||||
let msg = err.message ? err.message : JSON.stringify(err);
|
let msg: ReactNode = err.message ? err.message : JSON.stringify(err);
|
||||||
logger.log("Failed to join room:", msg);
|
logger.log("Failed to join room:", msg);
|
||||||
|
|
||||||
if (err.name === "ConnectionError") {
|
if (err.name === "ConnectionError") {
|
||||||
|
|
|
@ -57,7 +57,7 @@ export function messageForResourceLimitError(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function messageForSyncError(err: MatrixError | Error): ReactNode {
|
export function messageForSyncError(err: MatrixError): ReactNode {
|
||||||
if (err.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
|
if (err.errcode === 'M_RESOURCE_LIMIT_EXCEEDED') {
|
||||||
const limitError = messageForResourceLimitError(
|
const limitError = messageForResourceLimitError(
|
||||||
err.data.limit_type,
|
err.data.limit_type,
|
||||||
|
|
Loading…
Reference in New Issue