Skip to content

Commit c25436d

Browse files
Copilotd-gubert
andcommitted
Add rid to modal UIKit interactions when room context is available
Co-authored-by: d-gubert <[email protected]>
1 parent 0e855fe commit c25436d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

apps/meteor/client/uikit/hooks/useModalContextValue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ type UseModalContextValueParams = {
2222
blockId?: string;
2323
};
2424
}>;
25+
rid?: string;
2526
};
2627

2728
type UseModalContextValueReturn = ContextType<typeof UiKitContext>;
2829

29-
export const useModalContextValue = ({ view, errors, values, updateValues }: UseModalContextValueParams): UseModalContextValueReturn => {
30+
export const useModalContextValue = ({ view, errors, values, updateValues, rid }: UseModalContextValueParams): UseModalContextValueReturn => {
3031
const actionManager = useUiKitActionManager();
3132

3233
const emitInteraction = useMemo(() => actionManager.emitInteraction.bind(actionManager), [actionManager]);
@@ -51,6 +52,7 @@ export const useModalContextValue = ({ view, errors, values, updateValues }: Use
5152
blockId,
5253
value,
5354
},
55+
...(rid && { rid }),
5456
});
5557
},
5658
updateState: ({ actionId, value, /* ,appId, */ blockId = 'default' }) => {

apps/meteor/client/views/modal/uikit/UiKitModal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { UiKitContext } from '@rocket.chat/fuselage-ui-kit';
33
import { MarkupInteractionContext } from '@rocket.chat/gazzodown';
44
import type * as UiKit from '@rocket.chat/ui-kit';
55
import type { FormEvent } from 'react';
6+
import { useContext } from 'react';
67

78
import ModalBlock from './ModalBlock';
89
import { detectEmoji } from '../../../lib/utils/detectEmoji';
910
import { preventSyntheticEvent } from '../../../lib/utils/preventSyntheticEvent';
1011
import { useModalContextValue } from '../../../uikit/hooks/useModalContextValue';
1112
import { useUiKitActionManager } from '../../../uikit/hooks/useUiKitActionManager';
1213
import { useUiKitView } from '../../../uikit/hooks/useUiKitView';
14+
import { RoomContext } from '../../room/contexts/RoomContext';
1315

1416
type UiKitModalProps = {
1517
key: UiKit.ModalView['id']; // force re-mount when viewId changes
@@ -19,7 +21,8 @@ type UiKitModalProps = {
1921
const UiKitModal = ({ initialView }: UiKitModalProps) => {
2022
const actionManager = useUiKitActionManager();
2123
const { view, errors, values, updateValues, state } = useUiKitView(initialView);
22-
const contextValue = useModalContextValue({ view, errors, values, updateValues });
24+
const rid = useContext(RoomContext)?.rid;
25+
const contextValue = useModalContextValue({ view, errors, values, updateValues, rid });
2326

2427
const handleSubmit = useEffectEvent((e: FormEvent) => {
2528
preventSyntheticEvent(e);
@@ -32,6 +35,7 @@ const UiKitModal = ({ initialView }: UiKitModalProps) => {
3235
},
3336
},
3437
viewId: view.id,
38+
...(rid && { rid }),
3539
});
3640
});
3741

@@ -47,6 +51,7 @@ const UiKitModal = ({ initialView }: UiKitModalProps) => {
4751
},
4852
isCleared: false,
4953
},
54+
...(rid && { rid }),
5055
});
5156
});
5257

@@ -61,6 +66,7 @@ const UiKitModal = ({ initialView }: UiKitModalProps) => {
6166
},
6267
isCleared: true,
6368
},
69+
...(rid && { rid }),
6470
});
6571
});
6672

0 commit comments

Comments
 (0)