Skip to content

Commit 3161051

Browse files
committed
bugfix react hooks issue
1 parent 3c8d0df commit 3161051

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

web/src/components/common/ChatContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const ChatContent: React.FC<{content: ChatMessageContent, messageIndex?:
2222
const origin = url ? new URL(url).origin : '';
2323
const pageType = toolContext?.pageType || ''
2424
const embedConfigs = useSelector((state: RootState) => state.configs.embed);
25+
const cards = toolContext?.dbInfo?.cards || []
2526

2627
// Get messages to check if next message exists
2728
const thread = useSelector((state: RootState) => state.chat.activeThread)
@@ -54,7 +55,7 @@ export const ChatContent: React.FC<{content: ChatMessageContent, messageIndex?:
5455
{content.images.map(image => (
5556
<img src={image.url} key={image.url} />
5657
))}
57-
<Markdown content={processModelToUIText(contentTextWithMentionTags, origin, embedConfigs)} messageIndex={messageIndex} />
58+
<Markdown content={processModelToUIText(contentTextWithMentionTags, origin, embedConfigs, cards)} messageIndex={messageIndex} />
5859
</div>
5960
)
6061
} else {

web/src/helpers/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export type MxModel = {
6262
}
6363
}
6464

65-
const useAppStore = getApp().useStore()
66-
6765
const controller = getApp().actionController
6866
export const getActionTaskLiteLabels = (action: string) => {
6967
const extraMapping: { [key: string]: string } = {
@@ -88,7 +86,7 @@ export const getActionTaskLiteLabels = (action: string) => {
8886
}
8987

9088

91-
export const processModelToUIText = (text: string, origin: string, embedConfigs: EmbedConfigs = {}): string => {
89+
export const processModelToUIText = (text: string, origin: string, embedConfigs: EmbedConfigs = {}, cards: object[] = []): string => {
9290
if (text === ''){
9391
return ''
9492
}
@@ -99,7 +97,6 @@ export const processModelToUIText = (text: string, origin: string, embedConfigs:
9997
.replace(/\]\]/g, '`]')
10098
}
10199
if (text.includes("card_id:") && (origin != '')) {
102-
const cards = useAppStore((state) => state.toolContext?.dbInfo?.cards) || [];
103100
//Replace [card_id:<id>] with link
104101
// Replace [card_id:<id>] with markdown link using embed URL logic
105102
text = text.replace(/\[card_id:(\d+)\]/g, (match, id) => {

0 commit comments

Comments
 (0)