Merge pull request #6215 from matrix-org/t3chguy/ts/5
This commit is contained in:
commit
e0aa142db7
28 changed files with 142 additions and 138 deletions
13
src/@types/global.d.ts
vendored
13
src/@types/global.d.ts
vendored
|
@ -113,19 +113,6 @@ declare global {
|
||||||
usageDetails?: {[key: string]: number};
|
usageDetails?: {[key: string]: number};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISettledFulfilled<T> {
|
|
||||||
status: "fulfilled";
|
|
||||||
value: T;
|
|
||||||
}
|
|
||||||
export interface ISettledRejected {
|
|
||||||
status: "rejected";
|
|
||||||
reason: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PromiseConstructor {
|
|
||||||
allSettled<T>(promises: Promise<T>[]): Promise<Array<ISettledFulfilled<T> | ISettledRejected>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HTMLAudioElement {
|
interface HTMLAudioElement {
|
||||||
type?: string;
|
type?: string;
|
||||||
// sinkId & setSinkId are experimental and typescript doesn't know about them
|
// sinkId & setSinkId are experimental and typescript doesn't know about them
|
||||||
|
|
|
@ -17,13 +17,12 @@ limitations under the License.
|
||||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
import { User } from "matrix-js-sdk/src/models/user";
|
import { User } from "matrix-js-sdk/src/models/user";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
import { ResizeMethod } from "matrix-js-sdk/src/@types/partials";
|
||||||
|
|
||||||
import DMRoomMap from './utils/DMRoomMap';
|
import DMRoomMap from './utils/DMRoomMap';
|
||||||
import { mediaFromMxc } from "./customisations/Media";
|
import { mediaFromMxc } from "./customisations/Media";
|
||||||
import SettingsStore from "./settings/SettingsStore";
|
import SettingsStore from "./settings/SettingsStore";
|
||||||
|
|
||||||
export type ResizeMethod = "crop" | "scale";
|
|
||||||
|
|
||||||
// Not to be used for BaseAvatar urls as that has similar default avatar fallback already
|
// Not to be used for BaseAvatar urls as that has similar default avatar fallback already
|
||||||
export function avatarUrlForMember(
|
export function avatarUrlForMember(
|
||||||
member: RoomMember,
|
member: RoomMember,
|
||||||
|
|
|
@ -17,8 +17,8 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { User } from "matrix-js-sdk/src/models/user";
|
||||||
|
|
||||||
import * as ContentHelpers from 'matrix-js-sdk/src/content-helpers';
|
import * as ContentHelpers from 'matrix-js-sdk/src/content-helpers';
|
||||||
import {MatrixClientPeg} from './MatrixClientPeg';
|
import {MatrixClientPeg} from './MatrixClientPeg';
|
||||||
|
@ -1019,9 +1019,8 @@ export const Commands = [
|
||||||
const member = MatrixClientPeg.get().getRoom(roomId).getMember(userId);
|
const member = MatrixClientPeg.get().getRoom(roomId).getMember(userId);
|
||||||
dis.dispatch<ViewUserPayload>({
|
dis.dispatch<ViewUserPayload>({
|
||||||
action: Action.ViewUser,
|
action: Action.ViewUser,
|
||||||
// XXX: We should be using a real member object and not assuming what the
|
// XXX: We should be using a real member object and not assuming what the receiver wants.
|
||||||
// receiver wants.
|
member: member || { userId } as User,
|
||||||
member: member || {userId},
|
|
||||||
});
|
});
|
||||||
return success();
|
return success();
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,8 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ReactElement } from 'react';
|
import { ReactElement } from 'react';
|
||||||
import Room from 'matrix-js-sdk/src/models/room';
|
import { Room } from 'matrix-js-sdk/src/models/room';
|
||||||
|
|
||||||
import CommandProvider from './CommandProvider';
|
import CommandProvider from './CommandProvider';
|
||||||
import CommunityProvider from './CommunityProvider';
|
import CommunityProvider from './CommunityProvider';
|
||||||
import DuckDuckGoProvider from './DuckDuckGoProvider';
|
import DuckDuckGoProvider from './DuckDuckGoProvider';
|
||||||
|
|
|
@ -15,7 +15,8 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Room from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
|
||||||
import AutocompleteProvider from './AutocompleteProvider';
|
import AutocompleteProvider from './AutocompleteProvider';
|
||||||
import { _t } from '../languageHandler';
|
import { _t } from '../languageHandler';
|
||||||
import {MatrixClientPeg} from '../MatrixClientPeg';
|
import {MatrixClientPeg} from '../MatrixClientPeg';
|
||||||
|
|
|
@ -18,7 +18,7 @@ limitations under the License.
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { uniqBy, sortBy } from "lodash";
|
import { uniqBy, sortBy } from "lodash";
|
||||||
import Room from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
|
||||||
import { _t } from '../languageHandler';
|
import { _t } from '../languageHandler';
|
||||||
import AutocompleteProvider from './AutocompleteProvider';
|
import AutocompleteProvider from './AutocompleteProvider';
|
||||||
|
|
|
@ -23,7 +23,7 @@ limitations under the License.
|
||||||
|
|
||||||
import React, { createRef } from 'react';
|
import React, { createRef } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { IRecommendedVersion, NotificationCountType, Room } from "matrix-js-sdk/src/models/room";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import { SearchResult } from "matrix-js-sdk/src/models/search-result";
|
import { SearchResult } from "matrix-js-sdk/src/models/search-result";
|
||||||
import { EventSubscription } from "fbemitter";
|
import { EventSubscription } from "fbemitter";
|
||||||
|
@ -172,11 +172,7 @@ export interface IState {
|
||||||
// We load this later by asking the js-sdk to suggest a version for us.
|
// We load this later by asking the js-sdk to suggest a version for us.
|
||||||
// This object is the result of Room#getRecommendedVersion()
|
// This object is the result of Room#getRecommendedVersion()
|
||||||
|
|
||||||
upgradeRecommendation?: {
|
upgradeRecommendation?: IRecommendedVersion;
|
||||||
version: string;
|
|
||||||
needsUpgrade: boolean;
|
|
||||||
urgent: boolean;
|
|
||||||
};
|
|
||||||
canReact: boolean;
|
canReact: boolean;
|
||||||
canReply: boolean;
|
canReply: boolean;
|
||||||
layout: Layout;
|
layout: Layout;
|
||||||
|
@ -2058,7 +2054,7 @@ export default class RoomView extends React.Component<IProps, IState> {
|
||||||
if (!this.state.atEndOfLiveTimeline && !this.state.searchResults) {
|
if (!this.state.atEndOfLiveTimeline && !this.state.searchResults) {
|
||||||
const JumpToBottomButton = sdk.getComponent('rooms.JumpToBottomButton');
|
const JumpToBottomButton = sdk.getComponent('rooms.JumpToBottomButton');
|
||||||
jumpToBottom = (<JumpToBottomButton
|
jumpToBottom = (<JumpToBottomButton
|
||||||
highlight={this.state.room.getUnreadNotificationCount('highlight') > 0}
|
highlight={this.state.room.getUnreadNotificationCount(NotificationCountType.Highlight) > 0}
|
||||||
numUnreadMessages={this.state.numUnreadMessages}
|
numUnreadMessages={this.state.numUnreadMessages}
|
||||||
onScrollToBottomClick={this.jumpToLiveTimeline}
|
onScrollToBottomClick={this.jumpToLiveTimeline}
|
||||||
roomId={this.state.roomId}
|
roomId={this.state.roomId}
|
||||||
|
|
|
@ -19,6 +19,8 @@ limitations under the License.
|
||||||
|
|
||||||
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { ResizeMethod } from 'matrix-js-sdk/src/@types/partials';
|
||||||
|
|
||||||
import * as AvatarLogic from '../../../Avatar';
|
import * as AvatarLogic from '../../../Avatar';
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import AccessibleButton from '../elements/AccessibleButton';
|
import AccessibleButton from '../elements/AccessibleButton';
|
||||||
|
@ -26,7 +28,6 @@ import RoomContext from "../../../contexts/RoomContext";
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
||||||
import { toPx } from "../../../utils/units";
|
import { toPx } from "../../../utils/units";
|
||||||
import {ResizeMethod} from "../../../Avatar";
|
|
||||||
import { _t } from '../../../languageHandler';
|
import { _t } from '../../../languageHandler';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
|
|
@ -15,10 +15,11 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { ResizeMethod } from 'matrix-js-sdk/src/@types/partials';
|
||||||
|
|
||||||
import BaseAvatar from './BaseAvatar';
|
import BaseAvatar from './BaseAvatar';
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { mediaFromMxc } from "../../../customisations/Media";
|
import { mediaFromMxc } from "../../../customisations/Media";
|
||||||
import {ResizeMethod} from "../../../Avatar";
|
|
||||||
|
|
||||||
export interface IProps {
|
export interface IProps {
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
|
|
@ -17,13 +17,13 @@ limitations under the License.
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
|
import { ResizeMethod } from 'matrix-js-sdk/src/@types/partials';
|
||||||
|
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import { Action } from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import BaseAvatar from "./BaseAvatar";
|
import BaseAvatar from "./BaseAvatar";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { mediaFromMxc } from "../../../customisations/Media";
|
import { mediaFromMxc } from "../../../customisations/Media";
|
||||||
import {ResizeMethod} from "../../../Avatar";
|
|
||||||
|
|
||||||
interface IProps extends Omit<React.ComponentProps<typeof BaseAvatar>, "name" | "idName" | "url"> {
|
interface IProps extends Omit<React.ComponentProps<typeof BaseAvatar>, "name" | "idName" | "url"> {
|
||||||
member: RoomMember;
|
member: RoomMember;
|
||||||
|
|
|
@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import React, { ComponentProps } from 'react';
|
import React, { ComponentProps } from 'react';
|
||||||
import Room from 'matrix-js-sdk/src/models/room';
|
import { Room } from 'matrix-js-sdk/src/models/room';
|
||||||
|
import { ResizeMethod } from 'matrix-js-sdk/src/@types/partials';
|
||||||
|
|
||||||
import BaseAvatar from './BaseAvatar';
|
import BaseAvatar from './BaseAvatar';
|
||||||
import ImageView from '../elements/ImageView';
|
import ImageView from '../elements/ImageView';
|
||||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import * as Avatar from '../../../Avatar';
|
import * as Avatar from '../../../Avatar';
|
||||||
import {ResizeMethod} from "../../../Avatar";
|
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { mediaFromMxc } from "../../../customisations/Media";
|
import { mediaFromMxc } from "../../../customisations/Media";
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {useEffect, useState} from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
|
||||||
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
||||||
|
@ -34,7 +34,7 @@ const RoomName = ({ room, children }: IProps): JSX.Element => {
|
||||||
}, [room]);
|
}, [room]);
|
||||||
|
|
||||||
if (children) return children(name);
|
if (children) return children(name);
|
||||||
return name || "";
|
return <>{ name || "" }</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default RoomName;
|
export default RoomName;
|
||||||
|
|
|
@ -15,6 +15,10 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
|
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||||
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
|
import { User } from "matrix-js-sdk/src/models/user";
|
||||||
|
import { PHASE_REQUESTED, PHASE_UNSENT } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||||
|
|
||||||
import EncryptionInfo from "./EncryptionInfo";
|
import EncryptionInfo from "./EncryptionInfo";
|
||||||
import VerificationPanel from "./VerificationPanel";
|
import VerificationPanel from "./VerificationPanel";
|
||||||
|
@ -22,11 +26,8 @@ import {MatrixClientPeg} from "../../../MatrixClientPeg";
|
||||||
import { ensureDMExists } from "../../../createRoom";
|
import { ensureDMExists } from "../../../createRoom";
|
||||||
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
import { useEventEmitter } from "../../../hooks/useEventEmitter";
|
||||||
import Modal from "../../../Modal";
|
import Modal from "../../../Modal";
|
||||||
import {PHASE_REQUESTED, PHASE_UNSENT} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
|
||||||
import * as sdk from "../../../index";
|
import * as sdk from "../../../index";
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import {VerificationRequest} from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
|
||||||
import {RoomMember} from "matrix-js-sdk/src/models/room-member";
|
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import { Action } from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
|
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
|
||||||
|
@ -35,7 +36,7 @@ import {RightPanelPhases} from "../../../stores/RightPanelStorePhases";
|
||||||
const MISMATCHES = ["m.key_mismatch", "m.user_error", "m.mismatched_sas"];
|
const MISMATCHES = ["m.key_mismatch", "m.user_error", "m.mismatched_sas"];
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
member: RoomMember;
|
member: RoomMember | User;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
verificationRequest: VerificationRequest;
|
verificationRequest: VerificationRequest;
|
||||||
verificationRequestPromise: Promise<VerificationRequest>;
|
verificationRequestPromise: Promise<VerificationRequest>;
|
||||||
|
|
|
@ -1594,7 +1594,7 @@ const UserInfo: React.FC<IProps> = ({
|
||||||
content = (
|
content = (
|
||||||
<BasicUserInfo
|
<BasicUserInfo
|
||||||
room={room}
|
room={room}
|
||||||
member={member}
|
member={member as User}
|
||||||
groupId={groupId as string}
|
groupId={groupId as string}
|
||||||
devices={devices}
|
devices={devices}
|
||||||
isRoomEncrypted={isRoomEncrypted} />
|
isRoomEncrypted={isRoomEncrypted} />
|
||||||
|
@ -1605,7 +1605,7 @@ const UserInfo: React.FC<IProps> = ({
|
||||||
content = (
|
content = (
|
||||||
<EncryptionPanel
|
<EncryptionPanel
|
||||||
{...props as React.ComponentProps<typeof EncryptionPanel>}
|
{...props as React.ComponentProps<typeof EncryptionPanel>}
|
||||||
member={member}
|
member={member as User | RoomMember}
|
||||||
onClose={onEncryptionPanelClose}
|
onClose={onEncryptionPanelClose}
|
||||||
isRoomEncrypted={isRoomEncrypted}
|
isRoomEncrypted={isRoomEncrypted}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -15,10 +15,12 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
|
||||||
import { Room } from 'matrix-js-sdk/src/models/room'
|
|
||||||
import AppsDrawer from './AppsDrawer';
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { lexicographicCompare } from 'matrix-js-sdk/src/utils';
|
||||||
|
import { Room } from 'matrix-js-sdk/src/models/room'
|
||||||
|
|
||||||
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||||
|
import AppsDrawer from './AppsDrawer';
|
||||||
import RateLimitedFunc from '../../../ratelimitedfunc';
|
import RateLimitedFunc from '../../../ratelimitedfunc';
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
|
||||||
|
@ -106,9 +108,7 @@ export default class AuxPanel extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
if (this.props.room && SettingsStore.getValue("feature_state_counters")) {
|
if (this.props.room && SettingsStore.getValue("feature_state_counters")) {
|
||||||
const stateEvs = this.props.room.currentState.getStateEvents('re.jki.counter');
|
const stateEvs = this.props.room.currentState.getStateEvents('re.jki.counter');
|
||||||
stateEvs.sort((a, b) => {
|
stateEvs.sort((a, b) => lexicographicCompare(a.getStateKey(), b.getStateKey()));
|
||||||
return a.getStateKey() < b.getStateKey();
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const ev of stateEvs) {
|
for (const ev of stateEvs) {
|
||||||
const title = ev.getContent().title;
|
const title = ev.getContent().title;
|
||||||
|
|
|
@ -16,6 +16,9 @@ limitations under the License.
|
||||||
|
|
||||||
import React, { useContext } from "react";
|
import React, { useContext } from "react";
|
||||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
import { User } from "matrix-js-sdk/src/models/user";
|
||||||
|
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
import RoomContext from "../../../contexts/RoomContext";
|
import RoomContext from "../../../contexts/RoomContext";
|
||||||
|
@ -30,14 +33,12 @@ import {Action} from "../../../dispatcher/actions";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import SpaceStore from "../../../stores/SpaceStore";
|
import SpaceStore from "../../../stores/SpaceStore";
|
||||||
import { showSpaceInvite } from "../../../utils/space";
|
import { showSpaceInvite } from "../../../utils/space";
|
||||||
|
|
||||||
import { privateShouldBeEncrypted } from "../../../createRoom";
|
import { privateShouldBeEncrypted } from "../../../createRoom";
|
||||||
|
|
||||||
import EventTileBubble from "../messages/EventTileBubble";
|
import EventTileBubble from "../messages/EventTileBubble";
|
||||||
import { ROOM_SECURITY_TAB } from "../dialogs/RoomSettingsDialog";
|
import { ROOM_SECURITY_TAB } from "../dialogs/RoomSettingsDialog";
|
||||||
|
|
||||||
function hasExpectedEncryptionSettings(room): boolean {
|
function hasExpectedEncryptionSettings(matrixClient: MatrixClient, room: Room): boolean {
|
||||||
const isEncrypted: boolean = room._client?.isRoomEncrypted(room.roomId);
|
const isEncrypted: boolean = matrixClient.isRoomEncrypted(room.roomId);
|
||||||
const isPublic: boolean = room.getJoinRule() === "public";
|
const isPublic: boolean = room.getJoinRule() === "public";
|
||||||
return isPublic || !privateShouldBeEncrypted() || isEncrypted;
|
return isPublic || !privateShouldBeEncrypted() || isEncrypted;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +62,7 @@ const NewRoomIntro = () => {
|
||||||
defaultDispatcher.dispatch<ViewUserPayload>({
|
defaultDispatcher.dispatch<ViewUserPayload>({
|
||||||
action: Action.ViewUser,
|
action: Action.ViewUser,
|
||||||
// XXX: We should be using a real member object and not assuming what the receiver wants.
|
// XXX: We should be using a real member object and not assuming what the receiver wants.
|
||||||
member: member || {userId: dmPartner},
|
member: member || { userId: dmPartner } as User,
|
||||||
});
|
});
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
|
@ -194,7 +195,7 @@ const NewRoomIntro = () => {
|
||||||
|
|
||||||
return <div className="mx_NewRoomIntro">
|
return <div className="mx_NewRoomIntro">
|
||||||
|
|
||||||
{ !hasExpectedEncryptionSettings(room) && (
|
{ !hasExpectedEncryptionSettings(cli, room) && (
|
||||||
<EventTileBubble
|
<EventTileBubble
|
||||||
className="mx_cryptoEvent mx_cryptoEvent_icon_warning"
|
className="mx_cryptoEvent mx_cryptoEvent_icon_warning"
|
||||||
title={_t("End-to-end encryption isn't enabled")}
|
title={_t("End-to-end encryption isn't enabled")}
|
||||||
|
|
|
@ -119,7 +119,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onLocalEchoUpdated = (ev: MatrixEvent, room: Room) => {
|
private onLocalEchoUpdated = (ev: MatrixEvent, room: Room) => {
|
||||||
if (!room?.roomId === this.props.room.roomId) return;
|
if (room?.roomId !== this.props.room.roomId) return;
|
||||||
this.setState({hasUnsentEvents: this.countUnsentEvents() > 0});
|
this.setState({hasUnsentEvents: this.countUnsentEvents() > 0});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
0,
|
0,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Unexpected tag ${tagId} applied to ${this.props.room.room_id}`);
|
console.warn(`Unexpected tag ${tagId} applied to ${this.props.room.roomId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ev as React.KeyboardEvent).key === Key.ENTER) {
|
if ((ev as React.KeyboardEvent).key === Key.ENTER) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Room from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
|
import { ResizeMethod } from "matrix-js-sdk/src/@types/partials";
|
||||||
|
|
||||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||||
import { IMediaEventContent, IPreparedMedia, prepEventContentAsMedia } from "./models/IMediaEventContent";
|
import { IMediaEventContent, IPreparedMedia, prepEventContentAsMedia } from "./models/IMediaEventContent";
|
||||||
import {ResizeMethod} from "../Avatar";
|
|
||||||
import {MatrixClient} from "matrix-js-sdk/src/client";
|
|
||||||
|
|
||||||
// Populate this class with the details of your customisations when copying it.
|
// Populate this class with the details of your customisations when copying it.
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
|
import { User } from "matrix-js-sdk/src/models/user";
|
||||||
import { ActionPayload } from "../payloads";
|
import { ActionPayload } from "../payloads";
|
||||||
import { Action } from "../actions";
|
import { Action } from "../actions";
|
||||||
|
|
||||||
|
@ -25,5 +26,5 @@ export interface ViewUserPayload extends ActionPayload {
|
||||||
* The member to view. May be null or falsy to indicate that no member
|
* The member to view. May be null or falsy to indicate that no member
|
||||||
* should be shown (hide whichever relevant components).
|
* should be shown (hide whichever relevant components).
|
||||||
*/
|
*/
|
||||||
member?: RoomMember;
|
member?: RoomMember | User;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ export class BanList {
|
||||||
if (!room) return;
|
if (!room) return;
|
||||||
|
|
||||||
for (const eventType of ALL_RULE_TYPES) {
|
for (const eventType of ALL_RULE_TYPES) {
|
||||||
const events = room.currentState.getStateEvents(eventType, undefined);
|
const events = room.currentState.getStateEvents(eventType);
|
||||||
for (const ev of events) {
|
for (const ev of events) {
|
||||||
if (!ev.getStateKey()) continue;
|
if (!ev.getStateKey()) continue;
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,9 @@ export class CommunityPrototypeStore extends AsyncStoreWithClient<IState> {
|
||||||
|
|
||||||
const pl = generalChat.currentState.getStateEvents("m.room.power_levels", "");
|
const pl = generalChat.currentState.getStateEvents("m.room.power_levels", "");
|
||||||
if (!pl) return this.isAdminOf(communityId);
|
if (!pl) return this.isAdminOf(communityId);
|
||||||
|
const plContent = pl.getContent();
|
||||||
|
|
||||||
const invitePl = isNullOrUndefined(pl.invite) ? 50 : Number(pl.invite);
|
const invitePl = isNullOrUndefined(plContent.invite) ? 50 : Number(plContent.invite);
|
||||||
return invitePl <= myMember.powerLevel;
|
return invitePl <= myMember.powerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +160,16 @@ export class CommunityPrototypeStore extends AsyncStoreWithClient<IState> {
|
||||||
if (SettingsStore.getValue("feature_communities_v2_prototypes")) {
|
if (SettingsStore.getValue("feature_communities_v2_prototypes")) {
|
||||||
const data = this.matrixClient.getAccountData("im.vector.group_info." + roomId);
|
const data = this.matrixClient.getAccountData("im.vector.group_info." + roomId);
|
||||||
if (data && data.getContent()) {
|
if (data && data.getContent()) {
|
||||||
return {displayName: data.getContent().name, avatarMxc: data.getContent().avatar_url};
|
return {
|
||||||
|
displayName: data.getContent().name,
|
||||||
|
avatarMxc: data.getContent().avatar_url,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {displayName: room.name, avatarMxc: room.avatar_url};
|
return {
|
||||||
|
displayName: room.name,
|
||||||
|
avatarMxc: room.getMxcAvatarUrl(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async onReady(): Promise<any> {
|
protected async onReady(): Promise<any> {
|
||||||
|
|
|
@ -276,7 +276,7 @@ class RoomViewStore extends Store<ActionPayload> {
|
||||||
const address = this.state.roomAlias || this.state.roomId;
|
const address = this.state.roomAlias || this.state.roomId;
|
||||||
const viaServers = this.state.viaServers || [];
|
const viaServers = this.state.viaServers || [];
|
||||||
try {
|
try {
|
||||||
await retry<void, MatrixError>(() => cli.joinRoom(address, {
|
await retry<any, MatrixError>(() => cli.joinRoom(address, {
|
||||||
viaServers,
|
viaServers,
|
||||||
...payload.opts,
|
...payload.opts,
|
||||||
}), NUM_JOIN_RETRY, (err) => {
|
}), NUM_JOIN_RETRY, (err) => {
|
||||||
|
|
|
@ -134,7 +134,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
// if the space being selected is an invite then always view that invite
|
// if the space being selected is an invite then always view that invite
|
||||||
// else if the last viewed room in this space is joined then view that
|
// else if the last viewed room in this space is joined then view that
|
||||||
// else view space home or home depending on what is being clicked on
|
// else view space home or home depending on what is being clicked on
|
||||||
if (space?.getMyMembership !== "invite" &&
|
if (space?.getMyMembership() !== "invite" &&
|
||||||
this.matrixClient?.getRoom(roomId)?.getMyMembership() === "join"
|
this.matrixClient?.getRoom(roomId)?.getMyMembership() === "join"
|
||||||
) {
|
) {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
|
@ -424,8 +424,14 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
parent = this.rootSpaces.find(s => this.spaceFilteredRooms.get(s.roomId)?.has(roomId));
|
parent = this.rootSpaces.find(s => this.spaceFilteredRooms.get(s.roomId)?.has(roomId));
|
||||||
}
|
}
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
const parents = Array.from(this.parentMap.get(roomId) || []);
|
const parentIds = Array.from(this.parentMap.get(roomId) || []);
|
||||||
parent = parents.find(p => this.matrixClient.getRoom(p));
|
for (const parentId of parentIds) {
|
||||||
|
const room = this.matrixClient.getRoom(parentId);
|
||||||
|
if (room) {
|
||||||
|
parent = room;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't trigger a context switch when we are switching a space to match the chosen room
|
// don't trigger a context switch when we are switching a space to match the chosen room
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { setHasDiff } from "../../../utils/sets";
|
||||||
* + All DMs
|
* + All DMs
|
||||||
*/
|
*/
|
||||||
export class SpaceFilterCondition extends EventEmitter implements IFilterCondition, IDestroyable {
|
export class SpaceFilterCondition extends EventEmitter implements IFilterCondition, IDestroyable {
|
||||||
private roomIds = new Set<Room>();
|
private roomIds = new Set<string>();
|
||||||
private space: Room = null;
|
private space: Room = null;
|
||||||
|
|
||||||
public get kind(): FilterKind {
|
public get kind(): FilterKind {
|
||||||
|
|
|
@ -1,30 +1,31 @@
|
||||||
|
/*
|
||||||
|
Copyright 2021 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.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
|
||||||
import DMRoomMap from './DMRoomMap';
|
import DMRoomMap from './DMRoomMap';
|
||||||
|
|
||||||
/* For now, a cut-down type spec for the client */
|
|
||||||
interface Client {
|
|
||||||
getUserId: () => string;
|
|
||||||
checkUserTrust: (userId: string) => {
|
|
||||||
isCrossSigningVerified: () => boolean
|
|
||||||
wasCrossSigningVerified: () => boolean
|
|
||||||
};
|
|
||||||
getStoredDevicesForUser: (userId: string) => [{ deviceId: string }];
|
|
||||||
checkDeviceTrust: (userId: string, deviceId: string) => {
|
|
||||||
isVerified: () => boolean
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Room {
|
|
||||||
getEncryptionTargetMembers: () => Promise<[{userId: string}]>;
|
|
||||||
roomId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum E2EStatus {
|
export enum E2EStatus {
|
||||||
Warning = "warning",
|
Warning = "warning",
|
||||||
Verified = "verified",
|
Verified = "verified",
|
||||||
Normal = "normal"
|
Normal = "normal"
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function shieldStatusForRoom(client: Client, room: Room): Promise<E2EStatus> {
|
export async function shieldStatusForRoom(client: MatrixClient, room: Room): Promise<E2EStatus> {
|
||||||
const members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId);
|
const members = (await room.getEncryptionTargetMembers()).map(({userId}) => userId);
|
||||||
const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
const inDMMap = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as url from "url";
|
import * as url from "url";
|
||||||
|
import { Capability, IWidget, IWidgetData, MatrixCapabilities } from "matrix-widget-api";
|
||||||
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
|
|
||||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||||
import SdkConfig from "../SdkConfig";
|
import SdkConfig from "../SdkConfig";
|
||||||
|
@ -23,11 +26,9 @@ import dis from '../dispatcher/dispatcher';
|
||||||
import WidgetEchoStore from '../stores/WidgetEchoStore';
|
import WidgetEchoStore from '../stores/WidgetEchoStore';
|
||||||
import SettingsStore from "../settings/SettingsStore";
|
import SettingsStore from "../settings/SettingsStore";
|
||||||
import { IntegrationManagers } from "../integrations/IntegrationManagers";
|
import { IntegrationManagers } from "../integrations/IntegrationManagers";
|
||||||
import {Room} from "matrix-js-sdk/src/models/room";
|
|
||||||
import { WidgetType } from "../widgets/WidgetType";
|
import { WidgetType } from "../widgets/WidgetType";
|
||||||
import { objectClone } from "./objects";
|
import { objectClone } from "./objects";
|
||||||
import { _t } from "../languageHandler";
|
import { _t } from "../languageHandler";
|
||||||
import {Capability, IWidget, IWidgetData, MatrixCapabilities} from "matrix-widget-api";
|
|
||||||
import { IApp } from "../stores/WidgetStore";
|
import { IApp } from "../stores/WidgetStore";
|
||||||
|
|
||||||
// How long we wait for the state event echo to come back from the server
|
// How long we wait for the state event echo to come back from the server
|
||||||
|
@ -377,9 +378,9 @@ export default class WidgetUtils {
|
||||||
return widgets.filter(w => w.content && w.content.type === "m.integration_manager");
|
return widgets.filter(w => w.content && w.content.type === "m.integration_manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
static getRoomWidgetsOfType(room: Room, type: WidgetType): IWidgetEvent[] {
|
static getRoomWidgetsOfType(room: Room, type: WidgetType): MatrixEvent[] {
|
||||||
const widgets = WidgetUtils.getRoomWidgets(room);
|
const widgets = WidgetUtils.getRoomWidgets(room) || [];
|
||||||
return (widgets || []).filter(w => {
|
return widgets.filter(w => {
|
||||||
const content = w.getContent();
|
const content = w.getContent();
|
||||||
return content.url && type.matches(content.type);
|
return content.url && type.matches(content.type);
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ import DMRoomMap from "../../../src/utils/DMRoomMap";
|
||||||
configure({ adapter: new Adapter() });
|
configure({ adapter: new Adapter() });
|
||||||
|
|
||||||
let client;
|
let client;
|
||||||
const room = new Matrix.Room();
|
const room = new Matrix.Room("!roomId:server_name");
|
||||||
|
|
||||||
// wrap MessagePanel with a component which provides the MatrixClient in the context.
|
// wrap MessagePanel with a component which provides the MatrixClient in the context.
|
||||||
class WrappedMessagePanel extends React.Component {
|
class WrappedMessagePanel extends React.Component {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue