Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc5d41c

Browse files
committed
fix issue with timeout
1 parent8dc00aa commitfc5d41c

File tree

7 files changed

+57
-20
lines changed

7 files changed

+57
-20
lines changed

‎src/editor/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
6060
webview.send({type:'TEST_PASS', payload})
6161
},
6262
onFail:(payload:Payload,message:string)=>{
63-
// send test fail message back to client
64-
webview.send({type:'TEST_FAIL', payload})
63+
// send test fail message back to client with failure message
64+
webview.send({type:'TEST_FAIL',payload:{ ...payload, message}})
6565
},
6666
onError:(payload:Payload)=>{
6767
// send test error message back to client

‎web-app/src/components/Message/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import * as React from 'react'
33

44
interfaceProps{
55
type?:'success'|'warning'|'error'|'notice'|'help'|'loading'
6-
title:string
76
shape?:'inline'|'addon'|'toast'
87
size?:'medium'|'large'
9-
children?:string
8+
title:string
9+
content?:string
10+
closed?:boolean
1011
closeable?:boolean
1112
onClose?:()=>void
1213
handleClose?:()=>void
@@ -23,13 +24,13 @@ const Message = (props: Props) => {
2324
return(
2425
<AlifdMessage
2526
type={props.type}
26-
visible={visible}
27+
visible={props.closed ?!props.closed :visible}
2728
title={props.title}
2829
closeable={props.closeable}
2930
onClose={onClose}
3031
shape={props.shape}
3132
>
32-
{props.children}
33+
{props.content}
3334
</AlifdMessage>
3435
)
3536
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
importMessagefrom'../Message'
2+
import*asReactfrom'react'
3+
import*asTfrom'typings'
4+
import{css,jsx}from'@emotion/core'
5+
6+
constdurations={
7+
success:1000,
8+
warning:4500,
9+
error:4500,
10+
loading:Infinity,
11+
}
12+
13+
constuseTimeout=({ duration, key}:{duration:number;key:string})=>{
14+
const[timeoutClose,setTimeoutClose]=React.useState(false)
15+
React.useEffect(()=>{
16+
setTimeoutClose(false)
17+
consttimeout=setTimeout(()=>{
18+
setTimeoutClose(true)
19+
},duration)
20+
return()=>{
21+
clearTimeout(timeout)
22+
}
23+
},[key])
24+
returntimeoutClose
25+
}
26+
27+
constTestMessage=(props:T.TestStatus)=>{
28+
constduration=durations[props.type]
29+
consttimeoutClose=useTimeout({ duration,key:props.title})
30+
return(
31+
<Message
32+
key={props.title}
33+
type={props.type}
34+
title={props.title}
35+
closed={timeoutClose}
36+
size="medium"
37+
closeable={props.type!=='loading'}
38+
content={props.content}
39+
/>
40+
)
41+
}
42+
43+
exportdefaultTestMessage

‎web-app/src/components/ProcessMessages/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Message from '../Message'
22
import*asReactfrom'react'
33
import*asTfrom'typings'
44
import{css,jsx}from'@emotion/core'
5+
importTestMessagefrom'./TestMessage'
56

67
interfaceProps{
78
testStatus:T.TestStatus|null
@@ -18,21 +19,15 @@ const styles = {
1819
// display a list of active processes
1920
constProcessMessages=({ processes, testStatus}:Props)=>{
2021
if(testStatus){
21-
return(
22-
<Messagekey={testStatus.title}type={testStatus.type}title={testStatus.title}size="medium">
23-
{testStatus.content}
24-
</Message>
25-
)
22+
return<TestMessage{...testStatus}/>
2623
}
2724
if(!processes.length){
2825
returnnull
2926
}
3027
return(
3128
<divcss={styles.container}>
3229
{processes.map(process=>(
33-
<Messagekey={process.title}type="loading"size="medium"title={process.title}>
34-
{process.description}
35-
</Message>
30+
<Messagekey={process.title}type="loading"size="medium"title={process.title}content={process.description}/>
3631
))}
3732
</div>
3833
)

‎web-app/src/containers/LoadingPage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ const LoadingPage = ({ text, context }: Props) => {
2525
if(error){
2626
return(
2727
<divcss={styles.page}>
28-
<Messagetype="error"title={error.title}>
29-
{error.description}
30-
</Message>
28+
<Messagetype="error"title={error.title}content={error.description}/>
3129
</div>
3230
)
3331
}

‎web-app/src/containers/Tutorial/LevelPage/Level.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
108108
</div>
109109
</div>
110110

111-
{processes.length>0&&(
111+
{(testStatus||processes.length>0)&&(
112112
<divcss={styles.processes}>
113113
<ProcessMessagesprocesses={processes}testStatus={testStatus}/>
114114
</div>

‎web-app/src/services/state/actions/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const testActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
1818
}),
1919
//@ts-ignore
2020
testFail:assign({
21-
testStatus:()=>({
21+
testStatus:(context,event)=>({
2222
type:'warning',
2323
title:'Fail!',
24-
content:'Test failed for some reason',
24+
content:event.payload.message,
2525
}),
2626
}),
2727
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp