diff --git a/.env b/.env index e76d84956af12a0b45b665d93fdd88fb4dac1d48..3cfd9e661210be3a347dfebec4eef65fbce75050 100644 --- a/.env +++ b/.env @@ -1,5 +1,4 @@ REACT_APP_STYLEGUIDE_URL=https://styleguide.pir-test.eu -REACT_APP_API_BASE_URL=https://cf2021.pirati.cz/api -REACT_APP_WS_BASE_URL=wss://cf2021.pirati.cz/ws +REACT_APP_API_BASE_URL=https://cf2021.pir-test.eu/api REACT_APP_MATOMO_ID=135 REACT_APP_SENTRY_DSN=https://aa80453ff4d54b9a9c1b49e79060498a@sentry.pir-test.eu/14 diff --git a/src/App.jsx b/src/App.jsx index 3b7de1a50b93da18556e26b784f816459c73bcf4..904e3fb0527071f3d1e8bbebb4aaa1981d8cfa74 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -80,7 +80,6 @@ const LoadingComponent = ( const BaseApp = () => { initializeWSChannel.read(); - loadConfig.read(); return ( <Router> @@ -94,6 +93,16 @@ const BaseApp = () => { ); }; +const ConfiguredApp = () => { + loadConfig.read(); + + return ( + <Suspense fallback={LoadingComponent}> + <BaseApp /> + </Suspense> + ); +}; + const AuthenticatedApp = () => { const keycloakInitConfig = { onLoad: "check-sso", @@ -111,7 +120,7 @@ const AuthenticatedApp = () => { onEvent={onKeycloakEvent} > <Suspense fallback={LoadingComponent}> - <BaseApp /> + <ConfiguredApp /> </Suspense> </KeycloakProvider> </> diff --git a/src/actions/global-info.js b/src/actions/global-info.js index 6e8c268fe43fd701446c53e45dc8d7ae69506586..342d31ccdef346d7214e8d3feba9cc23b53e57c1 100644 --- a/src/actions/global-info.js +++ b/src/actions/global-info.js @@ -27,6 +27,9 @@ export const loadConfig = createAsyncAction( if (rawConfigItem.id === "stream_url") { state.streamUrl = rawConfigItem.value; } + if (rawConfigItem.id === "websocket_url") { + state.websocketUrl = rawConfigItem.value; + } }); }); } diff --git a/src/actions/ws.js b/src/actions/ws.js index 59150d3efe2c9ca2b46d0968aa5621a2c5f73f1a..6de984d7ad642eb9e46368d32c3ed09843600a63 100644 --- a/src/actions/ws.js +++ b/src/actions/ws.js @@ -1,5 +1,6 @@ import { createAsyncAction, errorResult, successResult } from "pullstate"; +import { GlobalInfoStore } from "stores"; import { connect } from "ws/connection"; import { loadAnnouncements } from "./announcements"; @@ -7,8 +8,11 @@ import { loadPosts } from "./posts"; import { loadProgram } from "./program"; export const initializeWSChannel = createAsyncAction(async () => { + const { websocketUrl } = GlobalInfoStore.getRawState(); + try { const wsChannel = await connect({ + url: websocketUrl, onConnect: async ({ worker }) => { // Re-load initial data once connected, this will ensure we won't lose // any intermediate state. diff --git a/src/components/annoucements/AnnouncementList.jsx b/src/components/annoucements/AnnouncementList.jsx index 898d2f9f354254de9c9154cd8e764e1b4b8c574b..7df00e6a4be87324de89dbdc0c3d90dd7677468d 100644 --- a/src/components/annoucements/AnnouncementList.jsx +++ b/src/components/annoucements/AnnouncementList.jsx @@ -39,6 +39,11 @@ const AnnouncementList = ({ onSeen={onAnnouncementSeen(item)} /> ))} + {!items.length && ( + <p className="px-8 py-4 leading-snug text-sm md:text-base"> + Zatím žádná oznámení. + </p> + )} </div> ); }; diff --git a/src/components/posts/PostList.jsx b/src/components/posts/PostList.jsx index ccfa7212899e270d7f40209caa144f67a3b4bfaa..170a9587eb770d8fae8703a18c4fea16300abe7b 100644 --- a/src/components/posts/PostList.jsx +++ b/src/components/posts/PostList.jsx @@ -84,7 +84,7 @@ const PostList = ({ /> ))} {!items.length && ( - <p className="p-4 lg:p-0 lg:py-3"> + <p className="p-4 lg:p-0 lg:py-3 leading-snug text-sm md:text-base"> Nikdo zatím žádný odpovídající příspěvek do rozpravy nepřidal. Budeš první? </p> diff --git a/src/containers/GlobalStats.jsx b/src/containers/GlobalStats.jsx index 8b3632d2b50f8e277c3bd067dcf496ca613cab48..d425afb8171ff827f4ca3791d96edb8c30cfb730 100644 --- a/src/containers/GlobalStats.jsx +++ b/src/containers/GlobalStats.jsx @@ -23,7 +23,7 @@ const GlobalStats = () => { <span> {onlineMembers === 1 && "člen online"} {onlineMembers > 1 && onlineMembers < 4 && "členové online"} - {onlineMembers > 4 && "členovů online"} + {(onlineMembers === 0 || onlineMembers > 4) && "členů online"} </span> </div> <div> diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index a8794ff0bb87e276708d9a0f04fc9887dc21eafa..06ebfcf5f2d14591f081cbe90a7fd3a21e579a69 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -153,7 +153,7 @@ const Home = () => { return ( <> - <article className="container container--wide pt-8 lg:py-24 cf2021"> + <article className="container container--wide py-8 lg:py-24 cf2021"> <section className="cf2021__video"> <div className="flex justify-between mb-4 lg:mb-8"> <h1 className="head-alt-base lg:head-alt-lg"> diff --git a/src/pages/Program.jsx b/src/pages/Program.jsx index 8cceb31274b1f61e53903ab38027ec3cb1f82920..48172805968ec5d3ad8fbc861bf993d5d0c74ef5 100644 --- a/src/pages/Program.jsx +++ b/src/pages/Program.jsx @@ -1,6 +1,5 @@ import React from "react"; import { Link } from "react-router-dom"; -import classNames from "classnames"; import { format } from "date-fns"; import { activateProgramPoint } from "actions/program"; @@ -34,13 +33,7 @@ const Schedule = () => { const entry = items[id]; return ( <div - className={classNames( - "flex flex-col md:flex-row my-4 hover:opacity-100 transition duration-300", - { - "text-black": isCurrent, - "text-black opacity-50": !isCurrent, - } - )} + className="flex flex-col md:flex-row my-4 duration-300 text-black" key={entry.id} > <div className="w-28 md:text-right"> diff --git a/src/stores.js b/src/stores.js index 9f2111855f3744271bad746c610ce0a04380d8a6..38a0dfa80bd0654ff3f3e2161c7e04ed7a9bf716 100644 --- a/src/stores.js +++ b/src/stores.js @@ -6,6 +6,7 @@ const globalInfoStoreInitial = { connectionState: "connecting", onlineMembers: 0, onlineUsers: 0, + websocketUrl: null, streamUrl: null, }; diff --git a/src/ws/connection.js b/src/ws/connection.js index 04f274337f81ed1b7a12a3ab0874db151b197ac4..43bab6dfde75bffc4179686b2bd51403c875e929 100644 --- a/src/ws/connection.js +++ b/src/ws/connection.js @@ -59,14 +59,14 @@ const buildKeepalivePayload = async () => { }; }; -export const connect = ({ onConnect }) => { +export const connect = ({ url, onConnect }) => { return new Promise((resolve, reject) => { const worker = Worker(); GlobalInfoStore.update((state) => { state.connectionState = "connecting"; }); - const ws = new WebSocket(process.env.REACT_APP_WS_BASE_URL); + const ws = new WebSocket(url); let keepAliveInterval; console.log("[ws] Connecting ..."); @@ -107,7 +107,7 @@ export const connect = ({ onConnect }) => { ); clearInterval(keepAliveInterval); - setTimeout(() => connect({ onConnect }), 1000); + setTimeout(() => connect({ url, onConnect }), 1000); }; ws.onerror = (err) => { diff --git a/typings/cf2021.d.ts b/typings/cf2021.d.ts index 4b9d6284b1f7a44f79bb0707050d50cbbae745f6..154eab942829e0aa72758d97b8da0273eaeca055 100644 --- a/typings/cf2021.d.ts +++ b/typings/cf2021.d.ts @@ -2,6 +2,7 @@ declare namespace CF2021 { export interface GlobalInfoStorePayload { connectionState: "connected" | "offline" | "connecting"; onlineUsers: number; + websocketUrl: string; streamUrl?: string; }