mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix(ShareModal): wrap ShareMessageModal with Provider in context menu (#11434)
When sharing a message via context menu, the ShareMessageModal was not wrapped with the Conversation store Provider, causing "zustand provider not used as ancestor" error when useConversationStore was called. This fix adds the Provider wrapper consistent with other Actions components (Assistant/Actions, Task/Actions, etc.) that use the share modal. Fixes #11382 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,10 @@ import { sessionSelectors } from '@/store/session/selectors';
|
||||
import { useUserStore } from '@/store/user';
|
||||
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
|
||||
|
||||
import ShareMessageModal from '../components/ShareMessageModal';
|
||||
import ShareMessageModal, { type ShareModalProps } from '../components/ShareMessageModal';
|
||||
import {
|
||||
Provider,
|
||||
createStore,
|
||||
dataSelectors,
|
||||
messageStateSelectors,
|
||||
useConversationStore,
|
||||
@@ -187,13 +189,26 @@ export const useChatItemContextMenu = ({
|
||||
if (!item || item.role !== 'assistant') return;
|
||||
|
||||
createRawModal(
|
||||
ShareMessageModal,
|
||||
(props: ShareModalProps) => (
|
||||
<Provider
|
||||
createStore={() => {
|
||||
const state = storeApi.getState();
|
||||
return createStore({
|
||||
context: state.context,
|
||||
hooks: state.hooks,
|
||||
skipFetch: state.skipFetch,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<ShareMessageModal {...props} />
|
||||
</Provider>
|
||||
),
|
||||
{
|
||||
message: item,
|
||||
},
|
||||
{ onCloseKey: 'onCancel', openKey: 'open' },
|
||||
);
|
||||
}, [getMessage]);
|
||||
}, [getMessage, storeApi]);
|
||||
|
||||
const handleAction = useCallback(
|
||||
async (action: ContextMenuEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user