From bc404a509a31cdfc79644473563d7355e7f5dfc9 Mon Sep 17 00:00:00 2001
From: xaralis <filip.varecha@fragaria.cz>
Date: Tue, 21 Dec 2021 16:50:11 +0100
Subject: [PATCH] Revert "wip"

This reverts commit 80f7624d3eb7f7a58686859f1c81d79eca47db9e.
---
 src/App.jsx                                | 26 +++++----------
 src/actions/global-info.js                 | 27 ---------------
 src/components/routing/EventBoundRoute.jsx | 39 ----------------------
 src/pages/Index.jsx                        |  7 ----
 src/stores.js                              |  4 +--
 typings/cf2021.d.ts                        | 12 -------
 6 files changed, 10 insertions(+), 105 deletions(-)
 delete mode 100644 src/components/routing/EventBoundRoute.jsx
 delete mode 100644 src/pages/Index.jsx

diff --git a/src/App.jsx b/src/App.jsx
index a16bcee..4b983f2 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -8,17 +8,15 @@ import * as Sentry from "@sentry/react";
 import { Integrations } from "@sentry/tracing";
 
 import { loadAnnouncements } from "actions/announcements";
-import { loadConfig, loadEventList } from "actions/global-info";
+import { loadConfig } from "actions/global-info";
 import { loadPosts } from "actions/posts";
 import { loadProgram } from "actions/program";
 import { loadMe, refreshAccessToken } from "actions/users";
 import { initializeWSChannel } from "actions/ws";
 import Footer from "components/Footer";
 import Navbar from "components/Navbar";
-import EventBoundRoute from "components/routing/EventBoundRoute";
 import About from "pages/About";
 import Home from "pages/Home";
-import Index from "pages/Index";
 import NotFound from "pages/NotFound";
 import Program from "pages/Program";
 import Protocol from "pages/Protocol";
@@ -120,15 +118,10 @@ const BaseApp = () => {
         </Helmet>
         <Navbar />
         <Switch>
-          <Route exact path="/" children={<Index />} />
-          <EventBoundRoute exact path="/event/live" children={<Home />} />
-          <EventBoundRoute exact path="/event/program" children={<Program />} />
-          <EventBoundRoute
-            exact
-            path="/event/protocol"
-            children={<Protocol />}
-          />
-          <EventBoundRoute exact path="/event/about" children={<About />} />
+          <Route exact path="/" children={<Home />} />
+          <Route exact path="/program" children={<Program />} />
+          <Route exact path="/protocol" children={<Protocol />} />
+          <Route exact path="/about" children={<About />} />
           <Route component={NotFound} />
         </Switch>
         <Footer />
@@ -139,11 +132,10 @@ const BaseApp = () => {
 };
 
 const ConfiguredApp = () => {
-  // loadConfig.read();
-  // loadProgram.read();
-  // loadAnnouncements.read();
-  // loadPosts.read();
-  loadEventList.read();
+  loadConfig.read();
+  loadProgram.read();
+  loadAnnouncements.read();
+  loadPosts.read();
 
   return (
     <Suspense fallback={LoadingComponent}>
diff --git a/src/actions/global-info.js b/src/actions/global-info.js
index bb9a51a..11b518f 100644
--- a/src/actions/global-info.js
+++ b/src/actions/global-info.js
@@ -6,33 +6,6 @@ import { fetch } from "api";
 import { markdownConverter } from "markdown";
 import { GlobalInfoStore } from "stores";
 
-
-export const loadEventList = createAsyncAction(
-  async () => {
-    try {
-      const resp = await fetch("/events");
-      const payload = await resp.json();
-
-      if (!isArray(payload)) {
-        return errorResult([], "Unexpected response format");
-      }
-
-      return successResult(payload);
-    } catch (err) {
-      return errorResult([], err.toString());
-    }
-  },
-  {
-    postActionHook: ({ result }) => {
-      if (!result.error) {
-        GlobalInfoStore.update((state) => {
-          console.log(result.payload);
-        });
-      }
-    },
-  }
-);
-
 export const loadConfig = createAsyncAction(
   async () => {
     try {
diff --git a/src/components/routing/EventBoundRoute.jsx b/src/components/routing/EventBoundRoute.jsx
deleted file mode 100644
index 7e56269..0000000
--- a/src/components/routing/EventBoundRoute.jsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import React from "react";
-import { Redirect, Route } from "react-router-dom";
-import PropTypes from "prop-types";
-
-import { GlobalInfoStore } from "stores";
-
-const EventBoundRoute = ({
-  component: Component,
-  children,
-  fallbackTo = "/",
-  ...rest
-}) => {
-  const { eventId } = GlobalInfoStore.useState();
-
-  return (
-    <Route
-      {...rest}
-      render={(props) =>
-        !!eventId ? (
-          children ? (
-            children
-          ) : (
-            <Component {...props} />
-          )
-        ) : (
-          <Redirect to={fallbackTo} />
-        )
-      }
-    />
-  );
-};
-
-EventBoundRoute.propTypes = {
-  component: PropTypes.elementType,
-  children: PropTypes.node,
-  fallbackTo: PropTypes.string,
-};
-
-export default EventBoundRoute;
diff --git a/src/pages/Index.jsx b/src/pages/Index.jsx
deleted file mode 100644
index 30e21b8..0000000
--- a/src/pages/Index.jsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import React from "react";
-
-const Index = () => {
-  return <div></div>;
-};
-
-export default Index;
diff --git a/src/stores.js b/src/stores.js
index c856d17..6be388b 100644
--- a/src/stores.js
+++ b/src/stores.js
@@ -3,9 +3,7 @@ import { Store } from "pullstate";
 
 /** @type {CF2021.GlobalInfoStorePayload} */
 const globalInfoStoreInitial = {
-  currentEventId: null,
-  events: [],
-  connectionState: "offline",
+  connectionState: "connecting",
   onlineMembers: 0,
   onlineUsers: 0,
   groupSizeHalf: null,
diff --git a/typings/cf2021.d.ts b/typings/cf2021.d.ts
index 05d2755..b699e18 100644
--- a/typings/cf2021.d.ts
+++ b/typings/cf2021.d.ts
@@ -1,17 +1,5 @@
 declare namespace CF2021 {
-  interface EventDetails {
-    name: string;
-    type: 1 | 2 | 3;
-    description?: string;
-    start: Date;
-    stream: string;
-    banner: string;
-  }
-
   export interface GlobalInfoStorePayload {
-    // Current event selection
-    currentEventId: string;
-    events: EventDetails[];
     connectionState: "connected" | "offline" | "connecting";
     onlineMembers: number;
     onlineUsers: number;
-- 
GitLab