Skip to content

Commit 213a7db

Browse files
author
Rankin Zheng
committed
Update message body component to use activeStep prop
1 parent 77603e2 commit 213a7db

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/views/components/CurrentMessage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const CurrentMessage = observer((props: any) => {
8484
whiteSpace: 'break-spaces'
8585
},
8686
}}>
87-
<MessageBody messageType="bot" temp={true} >
87+
<MessageBody messageType="bot" activeStep={true} >
8888
{renderBlocks.length>0?toMarkdown(renderBlocks[0]):''}
8989
</MessageBody>
9090
<MessageBlink />

src/views/components/MessageBody/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface IProps {
88
messageType: string,
99
children: string,
1010
messageDone?: boolean,
11-
temp?: boolean
11+
activeStep?: boolean
1212
}
1313

1414

@@ -24,14 +24,14 @@ const useStyles = createStyles((theme, options:any) => ({
2424
}));
2525

2626
const MessageBody = observer((props: IProps) => {
27-
const { children, messageType, temp=false ,messageDone} = props;
27+
const { children, messageType, activeStep=false ,messageDone} = props;
2828
const { chat } = useMst();
2929
const {classes} = useStyles({
3030
chatPanelWidth:chat.chatPanelWidth
3131
});
3232
return (
3333
messageType === 'bot'
34-
? <MessageMarkdown className={classes.bodyWidth} temp={temp} messageDone={messageDone}>
34+
? <MessageMarkdown className={classes.bodyWidth} activeStep={activeStep} messageDone={messageDone}>
3535
{children}
3636
</MessageMarkdown>
3737
: <Container

src/views/components/MessageMarkdown/Step.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import { keyframes,css } from "@emotion/react";
1212
interface StepProps {
1313
language: string;
1414
children: string;
15-
done: boolean;
15+
status: string;
1616
index: number|undefined;
1717
}
1818

1919
const Step = observer((props:StepProps) => {
2020
const { chat } = useMst();
21-
const {language,children,done,index} = props;
21+
const {language,children,status,index} = props;
2222
const [opened, { toggle }] = useDisclosure(false);
2323

2424
// extract first line with # as button label
@@ -85,7 +85,7 @@ const Step = observer((props:StepProps) => {
8585
>
8686
<Accordion.Item value={'step'+index} mah='200'>
8787
<Accordion.Control icon={
88-
done
88+
status === "done"
8989
?<IconCheck size="1.125rem"/>
9090
:<Loader size="xs" color="#ED6A45" speed={1} />
9191
}

src/views/components/MessageMarkdown/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface MessageMarkdownProps extends React.ComponentProps<typeof ReactMarkdown
3333
children: string,
3434
className: string,
3535
messageDone?: boolean,
36-
temp?: boolean
36+
activeStep?: boolean
3737
}
3838

3939
type Step = {
@@ -54,7 +54,7 @@ function parseMetaData(string) {
5454
}
5555

5656
const MessageMarkdown = observer((props: MessageMarkdownProps) => {
57-
const { children,temp=false,messageDone } = props;
57+
const { children,activeStep=false,messageDone } = props;
5858
const { chat } = useMst();
5959
const [steps, setSteps] = useState<Step[]>([]);
6060
const tree = fromMarkdown(children);
@@ -177,7 +177,7 @@ Generate a professionally written and formatted release note in markdown with th
177177
return <ReactMarkdown
178178
{...props}
179179
remarkPlugins={[()=> (tree) =>{
180-
let stepCount = 1;
180+
let stepCount = 0;
181181
let chatmarkCount = 0;
182182
let previousNode:any = null;
183183
visit(tree, function (node) {
@@ -227,8 +227,8 @@ Generate a professionally written and formatted release note in markdown with th
227227
}
228228

229229
if (lanugage === 'step' || lanugage === 'Step') {
230-
let done = Number(index) < codes.length? true : lastNode.type !== 'code';
231-
return <Step language={lanugage} done={temp?done:true} index={index}>{value}</Step>;
230+
const status = activeStep && Number(index) === codes.length - 1 && lastNode.type === 'code' ? "running" : "done";
231+
return <Step language={lanugage} status={status} index={index}>{value}</Step>;
232232
}
233233

234234
if (lanugage === 'chatmark' || lanugage === 'ChatMark') {

0 commit comments

Comments
 (0)