Merge pull request #1540 from SkynetLabs/temporary-backwards-compatibility-code

temporary backwards compatibility code for accounts on website
This commit is contained in:
Karol Wypchło 2022-01-13 12:05:28 +01:00 committed by GitHub
commit 588e834db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -41,8 +41,8 @@ const Navigation = ({ mode, uri }) => {
}, [open]); }, [open]);
const mobileMenuOffset = navRef.current ? navRef.current.offsetTop : 0; const mobileMenuOffset = navRef.current ? navRef.current.offsetTop : 0;
const showLoginNavigation = accounts?.enabled && !accounts?.authenticated; const showLoginNavigation = accounts && accounts.enabled !== false && !accounts?.authenticated;
const showAccountNavigation = accounts?.enabled && accounts?.authenticated; const showAccountNavigation = accounts && accounts.enabled !== false && accounts?.authenticated;
return ( return (
<nav <nav

View File

@ -52,8 +52,10 @@ const Uploader = () => {
const [uploads, setUploads] = React.useState([]); const [uploads, setUploads] = React.useState([]);
const { data: accounts } = useAccounts(); const { data: accounts } = useAccounts();
const showAccountFeatures = accounts?.enabled && !accounts?.auth_required && !accounts?.authenticated; const showAccountFeatures =
const disabledComponent = accounts?.enabled && accounts?.auth_required && !accounts?.authenticated; accounts && accounts.enabled !== false && !accounts?.auth_required && !accounts?.authenticated;
const disabledComponent =
accounts && accounts.enabled !== false && accounts?.auth_required && !accounts?.authenticated;
const onUploadStateChange = React.useCallback((id, state) => { const onUploadStateChange = React.useCallback((id, state) => {
setUploads((uploads) => { setUploads((uploads) => {

View File

@ -1,7 +1,11 @@
import useSWR from "swr"; import useSWR from "swr";
const prefix = process.env.GATSBY_API_URL ?? ""; const prefix = process.env.GATSBY_API_URL ?? "";
const fetcher = (url) => fetch(`${prefix}${url}`).then((response) => response.json()); const fetcher = (url) =>
fetch(`${prefix}${url}`)
.then((response) => response.json())
// temporary backwards compatibility code until new nginx code is deployed
.catch((error) => console.log(error) || fetcher(url.replace("/accounts", "/authenticated")));
export default function useAccounts() { export default function useAccounts() {
return useSWR("/__internal/do/not/use/accounts", fetcher); return useSWR("/__internal/do/not/use/accounts", fetcher);