mirror of https://codeberg.org/pzp/zooboard.git
Make invite errors crash things less
This commit is contained in:
parent
eddecbe017
commit
d91adaa005
|
@ -16,6 +16,7 @@ function App() {
|
|||
const [excalidrawAPI, setExcalidrawAPI] = useState(null)
|
||||
|
||||
const [inviteCode, setInviteCode] = useState(null)
|
||||
const [inviteErr, setInviteErr] = useState(null)
|
||||
|
||||
const [inviteModalOpen, setInviteModalOpen] = useState(false)
|
||||
const openInviteModal = () => setInviteModalOpen(true)
|
||||
|
@ -45,7 +46,11 @@ function App() {
|
|||
setInviteCode(null)
|
||||
openInviteModal()
|
||||
window.electronAPI.createInvite().then((invite) => {
|
||||
setInviteErr(null)
|
||||
setInviteCode(invite)
|
||||
}).catch(err => {
|
||||
setInviteCode(null)
|
||||
setInviteErr(err)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -102,6 +107,7 @@ function App() {
|
|||
isOpen={inviteModalOpen}
|
||||
onClose={closeInviteModal}
|
||||
inviteCode={inviteCode}
|
||||
inviteErr={inviteErr}
|
||||
/>
|
||||
<JoinModal isOpen={joinModalOpen} onClose={closeJoinModal} />
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Button from './Button'
|
||||
import Modal from './Modal'
|
||||
|
||||
function CreateInviteModal({ isOpen, onClose, inviteCode }) {
|
||||
function CreateInviteModal({ isOpen, onClose, inviteCode, inviteErr }) {
|
||||
const copyInviteToClipboard = () => {
|
||||
window.electronAPI.copyToClipboard(inviteCode).then(() => {
|
||||
onClose()
|
||||
|
@ -20,7 +20,12 @@ function CreateInviteModal({ isOpen, onClose, inviteCode }) {
|
|||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose}>
|
||||
{inviteCode ? (
|
||||
{inviteErr ? (
|
||||
<>
|
||||
<div className="text-slate-500 h-14">Got an error when creating the invite:</div>
|
||||
<div className="text-slate-500 h-14">{inviteErr.toString()}</div>
|
||||
</>
|
||||
) : inviteCode ? (
|
||||
<>
|
||||
This is an invite code that you can send to a friend to collaborate on
|
||||
this drawing with you.
|
||||
|
|
Loading…
Reference in New Issue