diff --git a/app/containers/MessageComposer/MessageComposer.test.tsx b/app/containers/MessageComposer/MessageComposer.test.tsx index 644decabae8..5a2aabb0fd0 100644 --- a/app/containers/MessageComposer/MessageComposer.test.tsx +++ b/app/containers/MessageComposer/MessageComposer.test.tsx @@ -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'; @@ -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', diff --git a/app/stacks/types.ts b/app/stacks/types.ts index dfedeb49340..2bffa16dc8a 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -8,6 +8,7 @@ import { type IMessage, type IServer, type ISubscription, + type RoomType, type SubscriptionType, type TAnyMessageModel, type TChangeAvatarViewContext, @@ -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; diff --git a/app/views/RoomView/context.ts b/app/views/RoomView/context.ts index eb2e2d3d2db..edd8afcdb07 100644 --- a/app/views/RoomView/context.ts +++ b/app/views/RoomView/context.ts @@ -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; diff --git a/app/views/RoomView/definitions.ts b/app/views/RoomView/definitions.ts index 7301dfaa0f7..31efd35286f 100644 --- a/app/views/RoomView/definitions.ts +++ b/app/views/RoomView/definitions.ts @@ -5,6 +5,7 @@ import { type IBaseScreen, type ILastMessage, type ILoggedUser, + type RoomType, type TSubscriptionModel, type ICustomEmojis, type TMessageAction @@ -44,7 +45,7 @@ export interface IRoomViewState { | TSubscriptionModel | { rid: string; - t: string; + t: RoomType; name?: string; fname?: string; prid?: string; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 4b76f4b55d0..cc87fd7afa0 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -145,13 +145,13 @@ class RoomView extends React.Component { 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);