'use strict'; import React, {useState} from "react"; import * as ReactDOM from "react-dom/client"; function init() { const wrapper = document.querySelector('#screen'); const root = ReactDOM.createRoot(wrapper); const html = (); root.render(html); } function SyncScreen() { const [loading, setLoading] = useState(null); const [error, setError] = useState(null); return <>

Oops... Block not in sync.

{error &&

{error}

} {loading ? <> {loading === 'syncing' &&

Version upgrade in progress...

}

Please wait...

: <>

Your version of the block is not in sync with the cloud (not latest version).
Would you like to update it?

}
async function ignoreVersionSync() { // Add "ignore" query parameter to current URl and redirect. const url = new URL(window.location.href); url.searchParams.set('ignoreVersionSync', 'true'); window.location = url.href; } async function runSyncLogic() { setLoading('syncing'); let data = {}; try { const response = await fetch('/sync', { method: 'POST', body: JSON.stringify({block: getQueryParams().block}), headers: { 'Content-Type': 'application/json' } }); data = await response.json(); } catch (err) { setError('Error: ' + err.message); setLoading(false); return; } if (data.status !== 200) { setError(data.message); setLoading(false); return; } setTimeout(() => window.location.reload(), 1000); } // TODO: This function is used in multiple places (repeated code). // Move to a common place. function getQueryParams() { const urlParams = new URLSearchParams(window.location.search); const params = {}; for (const [key, value] of urlParams) { params[key] = value; } return params; } } init();