Fix season on safari
diff --git a/Components/NavBar.js b/Components/NavBar.js
index 0b81c84..ca078de 100644
--- a/Components/NavBar.js
+++ b/Components/NavBar.js
@@ -1,7 +1,6 @@
import React, { Component } from "react";
import Styles from '../styles/Components/navbar.module.css';
import ThemeChangeButton from './ThemeChangeButton';
-import { getSeason } from '../pages/api/season';
class Divider extends Component {
render() {
@@ -19,7 +18,7 @@
}
render() {
- const season = getSeason().filePath;
+ const season = this.props.season.filePath;
return (
<div className={Styles.cutoffContainer}>
<div className={Styles.container + " " + (this.props.subBar ? Styles.slideUp : null)}>
diff --git a/pages/_app.js b/pages/_app.js
index 7d1b810..2b1dbad 100644
--- a/pages/_app.js
+++ b/pages/_app.js
@@ -1,7 +1,7 @@
import '../styles/globals.css';
import NavBar from '../Components/NavBar';
import { ThemeProvider } from 'theme-ui';
-import React from 'react';
+import React, {useEffect} from 'react';
import Styles from '../styles/globals.module.css';
import { getSeason } from './api/season';
import Christmas from '../Components/overlays/christmas';
@@ -55,6 +55,13 @@
const [subBar, setSubBar] = React.useState(false);
const [currentElement, setElement] = React.useState(<></>);
+ const [season, setSeason] = React.useState({ season: "normal", filePath: "normal" });
+
+ useEffect(() => async () => {
+ let season = await (await fetch("/api/season")).json();
+ setSeason(season);
+ }, [season])
+
const showSubBar = (element, timeout, positioning="left") => {
setSubBar(true);
if (positioning === "center") {
@@ -79,7 +86,6 @@
showSubBar(<p className={Styles.message}>{text}</p>, 5, positioning);
}
- const season = getSeason();
let Overlay = <></>;
switch (season.season) {
case "christmas": {
@@ -97,6 +103,7 @@
setElement={setElement}
showMessage={showMessage}
showSubBar={showSubBar}
+ season={season}
/>
<Component
{...pageProps}