From 3ea6959175ad8bb47d6c5caf8c23d20fee43868c Mon Sep 17 00:00:00 2001 From: saml33 Date: Mon, 31 Oct 2022 12:48:22 +1100 Subject: [PATCH] allow close tour if settings data is unavailable --- components/tours/CustomTooltip.tsx | 60 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/components/tours/CustomTooltip.tsx b/components/tours/CustomTooltip.tsx index c954fcfa..6208b1de 100644 --- a/components/tours/CustomTooltip.tsx +++ b/components/tours/CustomTooltip.tsx @@ -22,35 +22,37 @@ const CustomTooltip = ({ const [loading, setLoading] = useState(false) const onClose = async () => { - if (!publicKey || !tourSettings) return - setLoading(true) - try { - const settings = { - ...tourSettings, + if (!publicKey) return + if (tourSettings) { + setLoading(true) + try { + const settings = { + ...tourSettings, + } + settings[hasSeenKey] = true + const message = JSON.stringify(settings) + const requestOptions = { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: message, + } + const response = await fetch( + 'https://mango-transaction-log.herokuapp.com/v4/user-data/settings-unsigned', + requestOptions + ) + if (response.status === 200) { + await actions.fetchTourSettings(publicKey.toString()) + } + } catch (e) { + console.log(e) + } finally { + if (customOnClose) { + customOnClose() + } + setLoading(false) + close() } - settings[hasSeenKey] = true - const message = JSON.stringify(settings) - const requestOptions = { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: message, - } - const response = await fetch( - 'https://mango-transaction-log.herokuapp.com/v4/user-data/settings-unsigned', - requestOptions - ) - if (response.status === 200) { - await actions.fetchTourSettings(publicKey.toString()) - } - } catch (e) { - console.log(e) - } finally { - if (customOnClose) { - customOnClose() - } - setLoading(false) - close() - } + } else close() } return ( @@ -95,7 +97,7 @@ const CustomTooltip = ({ ) : (