From f3ec3b0b88a43e2a48db51b81f9b5778ade11248 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sun, 8 Oct 2023 18:45:33 +0300
Subject: Fix initial auth from cookie
---
vnext/src/index.js | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
(limited to 'vnext/src/index.js')
diff --git a/vnext/src/index.js b/vnext/src/index.js
index 77f152af..7959186f 100644
--- a/vnext/src/index.js
+++ b/vnext/src/index.js
@@ -15,27 +15,38 @@ import { CookiesProvider } from 'react-cookie'
import { HelmetProvider } from 'react-helmet-async'
import { VisitorProvider } from './ui/VisitorContext'
+import { me } from './api'
const Juick = lazy(() => import('./App'))
const props = window.__PROPS__ ? JSON.parse(decodeURIComponent(escape(atob(window.__PROPS__)))) : {}
-const JuickApp = () => (
-
-
-
-
-
-
-
-
-
-
-
-)
-
-let root = document.getElementById('app')
-if (window.__PROPS__) {
- hydrateRoot(root, )
-} else {
- createRoot(root).render()
+function ready(fn) {
+ if (document.readyState != 'loading') {
+ fn()
+ } else {
+ document.addEventListener('DOMContentLoaded', fn)
+ }
}
+
+ready(async () => {
+ let visitor = await me()
+ const JuickApp = () => (
+
+
+
+
+
+
+
+
+
+
+
+ )
+ let root = document.getElementById('app')
+ if (window.__PROPS__) {
+ hydrateRoot(root, )
+ } else {
+ createRoot(root).render()
+ }
+})
--
cgit v1.2.3