Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/containers/MessageComposer/MessageComposer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { selectServerRequest } from '../../actions/server';
import { setUser } from '../../actions/login';
import { mockedStore } from '../../reducers/mockedStore';
import { type IPermissionsState } from '../../reducers/permissions';
import { type IMessage } from '../../definitions';
import { type IMessage, type RoomType } from '../../definitions';
import { colors } from '../../lib/constants/colors';
import { type IRoomContext, RoomContext } from '../../views/RoomView/context';
import * as EmojiKeyboardHook from './hooks/useEmojiKeyboard';
Expand Down Expand Up @@ -78,7 +78,7 @@ const initialContext = {
tmid: undefined,
room: {
rid: 'rid',
t: 'd',
t: 'd' as RoomType,
tmid: undefined,
name: 'Rocket Chat',
fname: 'Rocket Chat',
Expand Down
3 changes: 2 additions & 1 deletion app/stacks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type IMessage,
type IServer,
type ISubscription,
type RoomType,
type SubscriptionType,
type TAnyMessageModel,
type TChangeAvatarViewContext,
Expand Down Expand Up @@ -36,7 +37,7 @@ export type ChatsStackParamList = {
name?: string;
fname?: string;
prid?: string;
room?: TSubscriptionModel | { rid: string; t: string; name?: string; fname?: string; prid?: string };
room?: TSubscriptionModel | { rid: string; t: RoomType; name?: string; fname?: string; prid?: string };
jumpToMessageId?: string;
jumpToThreadId?: string;
roomUserId?: string | null;
Expand Down
23 changes: 22 additions & 1 deletion app/views/RoomView/context.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import { createContext, useContext } from 'react';

import { type ILastMessage, type RoomType, type TSubscriptionModel } from '../../definitions';

export type TMessageAction = 'reply' | 'quote' | 'edit' | 'react' | null;

/**
* Type for room in RoomContext, matching IRoomViewState.room
* Can be either a full TSubscriptionModel or a partial room object (e.g., for threads)
*/
export type TRoomContextRoom =
| TSubscriptionModel
| {
rid: string;
t: RoomType;
name?: string;
fname?: string;
prid?: string;
joinCodeRequired?: boolean;
status?: string;
lastMessage?: ILastMessage;
sysMes?: boolean;
onHold?: boolean;
};

export interface IRoomContext {
rid?: string;
t?: string;
tmid?: string;
room: any; // FIXME: type it properly after we migrate RoomView to hooks
room: TRoomContextRoom;
sharing?: boolean;
action?: TMessageAction;
isAutocompleteVisible?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion app/views/RoomView/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type IBaseScreen,
type ILastMessage,
type ILoggedUser,
type RoomType,
type TSubscriptionModel,
type ICustomEmojis,
type TMessageAction
Expand Down Expand Up @@ -44,7 +45,7 @@ export interface IRoomViewState {
| TSubscriptionModel
| {
rid: string;
t: string;
t: RoomType;
name?: string;
fname?: string;
prid?: string;
Expand Down
6 changes: 3 additions & 3 deletions app/views/RoomView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
const name = props.route.params?.name;
const fname = props.route.params?.fname;
const prid = props.route.params?.prid;
const room = props.route.params?.room ?? {
const room = (props.route.params?.room ?? {
rid: this.rid as string,
t: this.t as string,
t: (this.t as RoomType) || ('d' as RoomType),
name,
fname,
prid
};
}) as IRoomViewState['room'];
this.jumpToMessageId = props.route.params?.jumpToMessageId;
this.jumpToThreadId = props.route.params?.jumpToThreadId;
const roomUserId = props.route.params?.roomUserId ?? getUidDirectMessage(room);
Expand Down