Skip to content

Commit 894b762

Browse files
kakao-joo-yoonjoostory
authored andcommitted
인증 완료 progress 추가
1 parent 05602a3 commit 894b762

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

src/main/events/auth.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ module.exports = () => {
4242
.then(account => {
4343
evt.sender.send('receive-account', account)
4444
})
45+
evt.sender.send('request-auth-done')
4546
}, e => {
4647
console.error(e)
4748
evt.sender.send('receive-message', `오류가 발생했습니다. (${e.message})`)
49+
evt.sender.send('request-auth-done')
4850
})
4951
})
5052

src/renderer/components/index/AuthButton.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { useState } from 'react'
1+
import React, { useEffect, useState } from 'react'
22
import { ipcRenderer } from 'electron'
33
import {
4-
Button, Dialog, DialogTitle, makeStyles,
5-
List, ListItem, ListItemAvatar, ListItemText, Avatar
4+
Button, Dialog, DialogTitle, makeStyles, Box,
5+
List, ListItem, ListItemAvatar, ListItemText, Avatar, CircularProgress
66
} from '@material-ui/core'
77
import { Add } from '@material-ui/icons'
88
import Providers from '../../constants/Providers'
@@ -12,27 +12,59 @@ const useStyle = makeStyles(theme => ({
1212
width: '100%',
1313
marginTop: theme.spacing(1),
1414
marginBottom: theme.spacing(2)
15+
},
16+
dialogTitle: {
17+
padding: theme.spacing(1),
18+
textAlign: 'center'
19+
},
20+
dialogList: {
21+
width: 500
22+
},
23+
requestBox: {
24+
position: 'relative',
25+
width: 500,
26+
height: 320
27+
},
28+
requestBoxContent: {
29+
position: 'absolute',
30+
top: '50%',
31+
left: '50%',
32+
margin: '-20px 0 0 -20px'
1533
}
1634
}))
1735

1836
export default function AuthButton() {
1937
const classes = useStyle()
2038
const [open, setOpen] = useState(false)
39+
const [requestProvider, setRequestProvider] = useState(null)
2140

2241
function handleSelectProvider(provider) {
2342
setOpen(false)
43+
setRequestProvider(provider)
2444
ipcRenderer.send('request-auth', provider.name)
2545
}
2646

47+
function handleRequestAuthDone() {
48+
setOpen(false)
49+
setRequestProvider(null)
50+
}
51+
52+
useEffect(() => {
53+
ipcRenderer.on("request-auth-done", handleRequestAuthDone)
54+
return () => {
55+
ipcRenderer.removeListener("request-auth-done", handleRequestAuthDone)
56+
}
57+
}, [])
58+
2759
return (
2860
<>
2961
<Button onClick={() => setOpen(!open)} className={classes.btnAdd} color='primary' startIcon={<Add />}>
3062
새로운 블로그 연결
3163
</Button>
3264

3365
<Dialog open={open} onClose={() => setOpen(false)}>
34-
<DialogTitle>연결할 서비스 선택</DialogTitle>
35-
<List>
66+
<DialogTitle className={classes.dialogTitle}>연결할 서비스 선택</DialogTitle>
67+
<List className={classes.dialogList}>
3668
{Providers.map(provider =>
3769
<ListItem key={provider.name} button onClick={() => handleSelectProvider(provider)}>
3870
<ListItemAvatar>
@@ -45,6 +77,14 @@ export default function AuthButton() {
4577
)}
4678
</List>
4779
</Dialog>
80+
81+
<Dialog open={!!requestProvider} onClose={() => setRequestProvider(null)}>
82+
<DialogTitle className={classes.dialogTitle}>{requestProvider?.label} 연결 중</DialogTitle>
83+
<Box className={classes.requestBox}>
84+
<Avatar src={requestProvider?.logo} className={classes.requestBoxContent} />
85+
<CircularProgress className={classes.requestBoxContent} />
86+
</Box>
87+
</Dialog>
4888
</>
4989
)
5090
}

0 commit comments

Comments
 (0)