Skip to content
Merged
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
17 changes: 10 additions & 7 deletions app/containers/MessageActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const REFOCUS_BUFFER = 50;
const isVideoConf = (message: TAnyMessageModel) => message.t === 'videoconf';

export interface IMessageActionsProps {
room: TSubscriptionModel;
getRoom: () => TSubscriptionModel;
tmid?: string;
user: Pick<ILoggedUser, 'id'>;
editInit: (messageId: string) => void;
Expand Down Expand Up @@ -81,7 +81,7 @@ const MessageActions = memo(
forwardRef<IMessageActions, IMessageActionsProps>(
(
{
room,
getRoom,
tmid,
user,
editInit,
Expand Down Expand Up @@ -133,7 +133,7 @@ const MessageActions = memo(
createDirectMessagePermission,
createDiscussionOtherUserPermission
];
const result = await hasPermission(permission, room.rid);
const result = await hasPermission(permission, getRoom().rid);
permissions = {
hasEditPermission: result[0],
hasDeletePermission: result[1],
Expand Down Expand Up @@ -219,7 +219,7 @@ const MessageActions = memo(

const handleCreateDiscussion = (message: TAnyMessageModel) => {
logEvent(events.ROOM_MSG_ACTION_DISCUSSION);
const params = { message, channel: room, showCloseModal: true };
const params = { message, channel: getRoom(), showCloseModal: true };
if (isMasterDetail) {
Navigation.navigate('ModalStackNavigator', { screen: 'CreateDiscussionView', params });
} else {
Expand All @@ -239,7 +239,7 @@ const MessageActions = memo(
const handleUnread = async (message: TAnyMessageModel) => {
logEvent(events.ROOM_MSG_ACTION_UNREAD);
const { id: messageId, ts } = message;
const { rid } = room;
const { rid } = getRoom();
try {
const db = database.active;
const result = await markAsUnread({ messageId });
Expand Down Expand Up @@ -355,6 +355,7 @@ const MessageActions = memo(
};

const handleToggleTranslation = async (message: TAnyMessageModel) => {
const room = getRoom();
try {
if (!room.autoTranslateLanguage) {
return;
Expand Down Expand Up @@ -403,6 +404,7 @@ const MessageActions = memo(
};

const getConversationOptions = (message: TAnyMessageModel) => {
const room = getRoom();
const options: TActionSheetOptionsItem[] = [];
const videoConfBlock = isVideoConf(message);

Expand Down Expand Up @@ -474,6 +476,7 @@ const MessageActions = memo(
};

const getSharingOptions = (message: TAnyMessageModel) => {
const room = getRoom();
const options: TActionSheetOptionsItem[] = [];
const videoConfBlock = isVideoConf(message);

Expand Down Expand Up @@ -567,7 +570,7 @@ const MessageActions = memo(
}

// Toggle Auto-translate
if (room.autoTranslate && isFromAnotherUser) {
if (getRoom().autoTranslate && isFromAnotherUser) {
options.push({
title: I18n.t(message.autoTranslate !== false ? 'View_Original' : 'Translate'),
icon: 'language',
Expand Down Expand Up @@ -624,7 +627,7 @@ const MessageActions = memo(
headerHeight: HEADER_HEIGHT,
customHeader: (
<>
{!isReadOnly || room.reactWhenReadOnly ? (
{!isReadOnly || getRoom().reactWhenReadOnly ? (
<Header handleReaction={handleReaction} isMasterDetail={isMasterDetail} message={message} />
) : null}
</>
Expand Down
6 changes: 3 additions & 3 deletions app/views/RoomView/components/RoomMessageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ export const RoomMessageActions = ({
const user = useAppSelector(getUserSelector);
const readOnly = useReadOnly();

const getRoom = () => roomStore.getState().room as TSubscriptionModel;

if (!isSubscribed) {
return null;
}

const room = roomStore.getState().room as TSubscriptionModel;

return (
<>
<MessageActions
ref={messageActionsRef}
tmid={tmid}
room={room}
getRoom={getRoom}
user={user}
editInit={editInit}
replyInit={replyInit}
Expand Down
2 changes: 1 addition & 1 deletion app/views/RoomView/hooks/useRoomInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface IRunInitSetters {
// Marks the screen unsettled for the duration of one init() run. init() resolves on the invite
// early-return and on failure alike, so the finally is the only place that settles it; awaiting it is
// what keeps the footer from flickering. Lives outside the hook because the React Compiler cannot
// lower a try/finally inside a hook body (see reactCompilerContract.test.ts).
// lower a try/finally inside a hook body.
//
// `controller` belongs to this run alone and is never reset by a later one: once a newer run aborts
// it, this run stops writing for a screen that has already moved on.
Expand Down
80 changes: 0 additions & 80 deletions app/views/RoomView/reactCompilerContract.test.ts

This file was deleted.

Loading