Pass room creation opts for new rooms into RoomView

This commit is contained in:
Michael Telatynski 2021-03-01 17:54:53 +00:00
parent 483d56320c
commit c8fe3f7676
4 changed files with 16 additions and 2 deletions

View file

@ -55,6 +55,7 @@ import { IThreepidInvite } from "../../stores/ThreepidInviteStore";
import Modal from "../../Modal"; import Modal from "../../Modal";
import { ICollapseConfig } from "../../resizer/distributors/collapse"; import { ICollapseConfig } from "../../resizer/distributors/collapse";
import HostSignupContainer from '../views/host_signup/HostSignupContainer'; import HostSignupContainer from '../views/host_signup/HostSignupContainer';
import { IOpts } from "../../createRoom";
// We need to fetch each pinned message individually (if we don't already have it) // We need to fetch each pinned message individually (if we don't already have it)
// so each pinned message may trigger a request. Limit the number per room for sanity. // so each pinned message may trigger a request. Limit the number per room for sanity.
@ -91,6 +92,7 @@ interface IProps {
currentGroupId?: string; currentGroupId?: string;
currentGroupIsNew?: boolean; currentGroupIsNew?: boolean;
justRegistered?: boolean; justRegistered?: boolean;
roomJustCreatedOpts?: IOpts;
} }
interface IUsageLimit { interface IUsageLimit {
@ -619,6 +621,7 @@ class LoggedInView extends React.Component<IProps, IState> {
viaServers={this.props.viaServers} viaServers={this.props.viaServers}
key={this.props.currentRoomId || 'roomview'} key={this.props.currentRoomId || 'roomview'}
resizeNotifier={this.props.resizeNotifier} resizeNotifier={this.props.resizeNotifier}
justCreatedOpts={this.props.roomJustCreatedOpts}
/>; />;
break; break;

View file

@ -48,7 +48,7 @@ import * as Lifecycle from '../../Lifecycle';
import '../../stores/LifecycleStore'; import '../../stores/LifecycleStore';
import PageTypes from '../../PageTypes'; import PageTypes from '../../PageTypes';
import createRoom from "../../createRoom"; import createRoom, {IOpts} from "../../createRoom";
import {_t, _td, getCurrentLanguage} from '../../languageHandler'; import {_t, _td, getCurrentLanguage} from '../../languageHandler';
import SettingsStore from "../../settings/SettingsStore"; import SettingsStore from "../../settings/SettingsStore";
import ThemeController from "../../settings/controllers/ThemeController"; import ThemeController from "../../settings/controllers/ThemeController";
@ -144,6 +144,8 @@ interface IRoomInfo {
oob_data?: object; oob_data?: object;
via_servers?: string[]; via_servers?: string[];
threepid_invite?: IThreepidInvite; threepid_invite?: IThreepidInvite;
justCreatedOpts?: IOpts;
} }
/* eslint-enable camelcase */ /* eslint-enable camelcase */
@ -201,6 +203,7 @@ interface IState {
viaServers?: string[]; viaServers?: string[];
pendingInitialSync?: boolean; pendingInitialSync?: boolean;
justRegistered?: boolean; justRegistered?: boolean;
roomJustCreatedOpts?: IOpts;
} }
export default class MatrixChat extends React.PureComponent<IProps, IState> { export default class MatrixChat extends React.PureComponent<IProps, IState> {
@ -922,6 +925,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
roomOobData: roomInfo.oob_data, roomOobData: roomInfo.oob_data,
viaServers: roomInfo.via_servers, viaServers: roomInfo.via_servers,
ready: true, ready: true,
roomJustCreatedOpts: roomInfo.justCreatedOpts,
}, () => { }, () => {
this.notifyNewScreen('room/' + presentedId, replaceLast); this.notifyNewScreen('room/' + presentedId, replaceLast);
}); });

View file

@ -80,6 +80,8 @@ import { showToast as showNotificationsToast } from "../../toasts/DesktopNotific
import { RoomNotificationStateStore } from "../../stores/notifications/RoomNotificationStateStore"; import { RoomNotificationStateStore } from "../../stores/notifications/RoomNotificationStateStore";
import { Container, WidgetLayoutStore } from "../../stores/widgets/WidgetLayoutStore"; import { Container, WidgetLayoutStore } from "../../stores/widgets/WidgetLayoutStore";
import { objectHasDiff } from "../../utils/objects"; import { objectHasDiff } from "../../utils/objects";
import SpaceRoomView from "./SpaceRoomView";
import { IOpts } from "../../createRoom";
const DEBUG = false; const DEBUG = false;
let debuglog = function(msg: string) {}; let debuglog = function(msg: string) {};
@ -114,6 +116,7 @@ interface IProps {
autoJoin?: boolean; autoJoin?: boolean;
resizeNotifier: ResizeNotifier; resizeNotifier: ResizeNotifier;
justCreatedOpts?: IOpts;
// Called with the credentials of a registered user (if they were a ROU that transitioned to PWLU) // Called with the credentials of a registered user (if they were a ROU that transitioned to PWLU)
onRegistered?(credentials: IMatrixClientCreds): void; onRegistered?(credentials: IMatrixClientCreds): void;

View file

@ -75,7 +75,7 @@ interface ICreateOpts {
power_level_content_override?: object; power_level_content_override?: object;
} }
interface IOpts { export interface IOpts {
dmUserId?: string; dmUserId?: string;
createOpts?: ICreateOpts; createOpts?: ICreateOpts;
spinner?: boolean; spinner?: boolean;
@ -197,6 +197,9 @@ export default function createRoom(opts: IOpts): Promise<string | null> {
// room has been created, so we race here with the client knowing that // room has been created, so we race here with the client knowing that
// the room exists, causing things like // the room exists, causing things like
// https://github.com/vector-im/vector-web/issues/1813 // https://github.com/vector-im/vector-web/issues/1813
// Even if we were to block on the echo, servers tend to split the room
// state over multiple syncs so we can't atomically know when we have the
// entire thing.
if (opts.andView) { if (opts.andView) {
dis.dispatch({ dis.dispatch({
action: 'view_room', action: 'view_room',
@ -206,6 +209,7 @@ export default function createRoom(opts: IOpts): Promise<string | null> {
// so we are expecting the room to come down the sync // so we are expecting the room to come down the sync
// stream, if it hasn't already. // stream, if it hasn't already.
joining: true, joining: true,
justCreatedOpts: opts,
}); });
} }
CountlyAnalytics.instance.trackRoomCreate(startTime, roomId); CountlyAnalytics.instance.trackRoomCreate(startTime, roomId);