aboutsummaryrefslogtreecommitdiffstats
path: root/hooks/usePopup.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-09-06 23:13:22 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-09-06 23:13:22 +0200
commit569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a (patch)
tree8d1cb94a56d60b9d726222277b7516fc59895613 /hooks/usePopup.js
parent275bd1d0a9aea90696c145cf992d522a0d6b0aa8 (diff)
downloadmy_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.gz
my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.bz2
my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.zip
added stadard linter
Diffstat (limited to 'hooks/usePopup.js')
-rw-r--r--hooks/usePopup.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/hooks/usePopup.js b/hooks/usePopup.js
index 615d403..c1fca19 100644
--- a/hooks/usePopup.js
+++ b/hooks/usePopup.js
@@ -3,35 +3,34 @@ import Queue from 'helpers/queue'
const PopupContext = createContext()
-export const PopupProvider = ({children}) => {
+export const PopupProvider = ({ children }) => {
const [popupData, setPopupData] = useState()
const setPopup = p => {
Queue.enqueue(
() =>
- new Promise(r => {
+ new Promise(resolve => {
if (p.time) {
setPopupData(p)
setTimeout(() => {
- r(setPopupData());
- }, p.time);
+ resolve(setPopupData())
+ }, p.time)
} else {
setPopupData({
...p,
- ...(p.yes && {yes: {label: p.yes.label, action: () => p.yes.action().then(() => r(setPopupData()))}}),
- ...(p.no && {no: {label: p.no.label, action: () => p.no.action().then(() => {r(setPopupData())})}}),
+ ...(p.yes && { yes: { label: p.yes.label, action: () => p.yes.action().then(() => resolve(setPopupData())) } }),
+ ...(p.no && { no: { label: p.no.label, action: () => p.no.action().then(() => { resolve(setPopupData()) }) } })
})
}
})
- );
-
+ )
}
- return (
- <PopupContext.Provider value={{popupData, setPopup}}>
- {children}
- </PopupContext.Provider>
- )
+ return (
+ <PopupContext.Provider value={{ popupData, setPopup }}>
+ {children}
+ </PopupContext.Provider>
+ )
}
const usePopup = () => useContext(PopupContext)