aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/App.js')
-rw-r--r--vnext/src/App.js27
1 files changed, 10 insertions, 17 deletions
diff --git a/vnext/src/App.js b/vnext/src/App.js
index c7849418..f20d8db3 100644
--- a/vnext/src/App.js
+++ b/vnext/src/App.js
@@ -1,5 +1,5 @@
import { useState, useEffect, useRef, Fragment, useCallback } from 'react'
-import { Route, Link, Routes, useSearchParams } from 'react-router-dom'
+import { Route, Link, Routes } from 'react-router-dom'
import svg4everybody from 'svg4everybody'
@@ -12,11 +12,8 @@ import Chat from './ui/Chat'
import Header from './ui/Header'
import Post from './ui/Post'
import Thread from './ui/Thread'
-import Login from './ui/Login'
-import { useCookies } from 'react-cookie'
-
-import { me, trends } from './api'
+import { loginUrl, me, trends } from './api'
import { useVisitor } from './ui/VisitorContext'
import Avatar from './ui/Avatar'
import { Toaster } from 'react-hot-toast'
@@ -30,22 +27,20 @@ import { Toaster } from 'react-hot-toast'
export default function App({ footer }) {
let contentRef = useRef(null)
- const [, setCookie] = useCookies(['hash'])
const [allTrends, setAllTrends] = useState([])
const [visitor, setVisitor] = useVisitor()
- const params = useSearchParams()
-
useEffect(() => {
svg4everybody()
+ /*
if (params['hash']) {
setCookie('hash', params['hash'], { path: '/' })
let retpath = params['retpath'] || `${window.location.protocol}//${window.location.host}${window.location.pathname}`
window.history.replaceState({}, document.title, retpath)
- }
- }, [setCookie, footer, params])
+ }*/
+ }, [])
let updateStatus = useCallback(() => {
// refresh server visitor state (unread counters)
@@ -60,10 +55,9 @@ export default function App({ footer }) {
let es
if (visitor) {
if ('EventSource' in window) {
- const eventParams = new URLSearchParams({ hash: visitor.hash })
- let url = new URL(`https://juick.com/api/events?${eventParams.toString()}`)
- console.log(url.toString())
- es = new EventSource(url.toString())
+ es = new EventSource('/api/events', {
+ withCredentials: true
+ })
es.onopen = () => {
console.log('online')
}
@@ -123,10 +117,10 @@ export default function App({ footer }) {
<span className="desktop">Settings</span>
</Link>
</> :
- <Link to={{ pathname: '/login' }}>
+ <a href={`/login?retpath=${window.location.href}`}>
<Icon name="ei-user" size="s" />
<span className="desktop">Login</span>
- </Link>
+ </a>
}
<Link to={{ pathname: '/discover' }} rel="nofollow">
<Icon name="ei-search" size="s" />
@@ -168,7 +162,6 @@ export default function App({ footer }) {
<Route exact path="/home" element={<Home />} />
<Route exact path="/discover" element={<Discover />} />
<Route exact path="/settings" element={<Settings onChange={updateStatus} />} />
- <Route exact path="/login" element={<Login onAuth={updateStatus} />} />
<Route exact path="/post" element={<Post />} />
<Route exact path="/pm" element={<Contacts />} />
<Route exact path="/pm/:user" element={<Chat connection={eventSource} />} />