From 77ff3fccdb68fecda3ca338b94d7bfcd0c5ce198 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 29 Oct 2022 18:03:27 +0300 Subject: Trends and cleanup JSDoc --- vnext/src/App.js | 27 +++++++++++++++++++--- vnext/src/api/index.js | 59 +++++++++++++++++++++++++++++++++++++++++------- vnext/src/ui/Spinner.js | 4 ++++ vnext/src/utils/embed.js | 24 ++++++++++---------- 4 files changed, 91 insertions(+), 23 deletions(-) (limited to 'vnext') diff --git a/vnext/src/App.js b/vnext/src/App.js index e6798b31..4e235c46 100644 --- a/vnext/src/App.js +++ b/vnext/src/App.js @@ -1,4 +1,4 @@ -import { useState, useEffect, useRef } from 'react'; +import { useState, useEffect, useRef, Fragment } from 'react'; import { Route, Link, Routes } from 'react-router-dom'; import qs from 'qs'; @@ -17,16 +17,21 @@ import Login from './ui/Login'; import { useCookies } from 'react-cookie'; -import { me } from './api'; +import { me, trends } from './api'; /** - * + * + * @param {import('react').PropsWithChildren<{}> & { + * footer: string + * }} props props */ export default function App({ footer }) { let contentRef = useRef(null); const [cookie, setCookie] = useCookies(['hash']); + const [allTrends, setAllTrends] = useState([]); + useEffect(() => { svg4everybody(); let params = qs.parse(window.location.search.substring(1)); @@ -91,6 +96,13 @@ export default function App({ footer }) { }); }, [hash]); + useEffect(() => { + const getTrends = async () => { + setAllTrends(await trends()); + }; + getTrends(); + }, []); + /** * @param {import("./api").SecureUser} visitor */ @@ -127,6 +139,15 @@ export default function App({ footer }) { Settings >)} +