From b3038c6ab5798e04a3fa5d3c835e825b7b445f70 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 19 Sep 2020 18:14:23 +0100 Subject: [PATCH 1/7] Some TS fixes. --- src/navbar/index.tsx | 2 +- src/optionsMenu/helpers/VUMeter.tsx | 1 - src/showplanner/Player.tsx | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/navbar/index.tsx b/src/navbar/index.tsx index 0df75bc..1034cf5 100644 --- a/src/navbar/index.tsx +++ b/src/navbar/index.tsx @@ -83,7 +83,7 @@ export function NavBar() { target="_blank" onClick={(e) => { e.preventDefault(); - let w = window.open( + window.open( "http://ury.org.uk/timelord/", "URY - Timelord", "resizable,status" diff --git a/src/optionsMenu/helpers/VUMeter.tsx b/src/optionsMenu/helpers/VUMeter.tsx index 5e94074..9b07348 100644 --- a/src/optionsMenu/helpers/VUMeter.tsx +++ b/src/optionsMenu/helpers/VUMeter.tsx @@ -2,7 +2,6 @@ import React, { useRef, useLayoutEffect, useEffect, - useCallback, useState, HTMLProps, } from "react"; diff --git a/src/showplanner/Player.tsx b/src/showplanner/Player.tsx index 4fa5435..779e63b 100644 --- a/src/showplanner/Player.tsx +++ b/src/showplanner/Player.tsx @@ -36,7 +36,7 @@ function PlayerNumbers({ id }: { id: number }) { ]); }, 1000); return () => window.clearInterval(tickerRef.current); - }, []); + }); return ( <> From c16af23f21d972db1ed7955484f34d6e3b6f4068 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 23 Sep 2020 00:57:03 +0100 Subject: [PATCH 2/7] Fix React modal error. --- src/showplanner/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index bacb975..178cb22 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -42,6 +42,7 @@ import { OptionsMenu } from "../optionsMenu"; import { WelcomeModal } from "./WelcomeModal"; import { PisModal } from "./PISModal"; import "./channel.scss"; +import Modal from "react-modal"; function Channel({ id, data }: { id: number; data: PlanItem[] }) { return ( @@ -196,6 +197,10 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { planSaveError, planSaving, } = useSelector((state: RootState) => state.showplan); + + // Tell Modals that #root is the main page content, for accessability reasons. + Modal.setAppElement('#root'); + const session = useSelector((state: RootState) => state.session); const [showWelcomeModal, setShowWelcomeModal] = useState( From 825e46c9373b4c76fed4486a4cc83d717fbac5f5 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 23 Sep 2020 01:00:41 +0100 Subject: [PATCH 3/7] Fix TS warning of always overwritten types --- src/showplanner/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index 178cb22..4f92426 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -242,7 +242,6 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { // TODO: this is ugly, should be in redux const data = CML_CACHE[result.draggableId]; const newItem: TimeslotItem = { - type: "central", timeslotitemid: "I" + insertIndex, channel: parseInt(result.destination.droppableId, 10), weight: result.destination.index, @@ -255,7 +254,6 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { // TODO: this is ugly, should be in redux const data = AUX_CACHE[result.draggableId]; const newItem: TimeslotItem = { - type: "aux", timeslotitemid: "I" + insertIndex, channel: parseInt(result.destination.droppableId, 10), weight: result.destination.index, From 1a31dd18c1080e7f10e4ab409ee2d7a277ed16ca Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 19 Sep 2020 20:46:28 +0100 Subject: [PATCH 4/7] Fix some TSX warnings. --- src/navbar/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/navbar/index.tsx b/src/navbar/index.tsx index 1034cf5..3a63750 100644 --- a/src/navbar/index.tsx +++ b/src/navbar/index.tsx @@ -81,6 +81,7 @@ export function NavBar() { { e.preventDefault(); window.open( @@ -167,7 +168,6 @@ export function NavBar() { } id="timeslotDropdown" data-toggle="dropdown" - aria-haspopup="true" aria-expanded="false" > @@ -207,7 +207,6 @@ export function NavBar() { href={MYRADIO_NON_API_BASE + "/Profile/default/"} id="dropdown07" data-toggle="dropdown" - aria-haspopup="true" aria-expanded="false" > From a3cab9cfb002587d179d6782b714e231467dc527 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 23 Sep 2020 01:06:55 +0100 Subject: [PATCH 5/7] Set _blank noopener too. --- src/navbar/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/navbar/index.tsx b/src/navbar/index.tsx index 3a63750..6d856b2 100644 --- a/src/navbar/index.tsx +++ b/src/navbar/index.tsx @@ -81,7 +81,7 @@ export function NavBar() { { e.preventDefault(); window.open( From 0da722a55d71311538eb38e7b33a97026dd50f15 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 23 Sep 2020 01:11:53 +0100 Subject: [PATCH 6/7] Fix Persist Store JS error and Raygun middleware --- src/store.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/store.ts b/src/store.ts index 4aead80..41320f2 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,5 +1,5 @@ import raygun from "raygun4js"; -import { configureStore, Action, getDefaultMiddleware } from "@reduxjs/toolkit"; +import { configureStore, Action, getDefaultMiddleware, Middleware, Dispatch } from "@reduxjs/toolkit"; import rootReducer, { RootState } from "./rootReducer"; import { ThunkAction } from "redux-thunk"; import { @@ -7,18 +7,33 @@ import { mixerKeyboardShortcutsMiddleware, startNewsTimer, } from "./mixer/state"; -import { persistStore } from "redux-persist"; +import { + persistStore, + FLUSH, + REHYDRATE, + PAUSE, + PERSIST, + PURGE, + REGISTER +} from "redux-persist"; +const raygunMiddleware: Middleware < {}, RootState, Dispatch < any >> = (store) => (next) => (action) => { + raygun("recordBreadcrumb", "redux-action", action); + return next(action); +} + +// See https://github.com/rt2zz/redux-persist/issues/988 for getDefaultMiddleware tweak. const store = configureStore({ reducer: rootReducer, middleware: [ mixerMiddleware, mixerKeyboardShortcutsMiddleware, - (store) => (next) => (action) => { - raygun("recordBreadcrumb", "redux-action", action); - return next(action); - }, - ...getDefaultMiddleware(), + raygunMiddleware, + ...getDefaultMiddleware({ + serializableCheck: { + ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER] + } + }) ], }); From 90a8bbbd8efa503e621fd9d3e674992c3930af06 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Wed, 23 Sep 2020 19:13:01 +0100 Subject: [PATCH 7/7] Prettier --- src/showplanner/index.tsx | 2 +- src/store.ts | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index 4f92426..a530be4 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -199,7 +199,7 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { } = useSelector((state: RootState) => state.showplan); // Tell Modals that #root is the main page content, for accessability reasons. - Modal.setAppElement('#root'); + Modal.setAppElement("#root"); const session = useSelector((state: RootState) => state.session); diff --git a/src/store.ts b/src/store.ts index 41320f2..adc5347 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,5 +1,11 @@ import raygun from "raygun4js"; -import { configureStore, Action, getDefaultMiddleware, Middleware, Dispatch } from "@reduxjs/toolkit"; +import { + configureStore, + Action, + getDefaultMiddleware, + Middleware, + Dispatch, +} from "@reduxjs/toolkit"; import rootReducer, { RootState } from "./rootReducer"; import { ThunkAction } from "redux-thunk"; import { @@ -14,13 +20,15 @@ import { PAUSE, PERSIST, PURGE, - REGISTER + REGISTER, } from "redux-persist"; -const raygunMiddleware: Middleware < {}, RootState, Dispatch < any >> = (store) => (next) => (action) => { +const raygunMiddleware: Middleware<{}, RootState, Dispatch> = (store) => ( + next +) => (action) => { raygun("recordBreadcrumb", "redux-action", action); return next(action); -} +}; // See https://github.com/rt2zz/redux-persist/issues/988 for getDefaultMiddleware tweak. const store = configureStore({ @@ -31,9 +39,9 @@ const store = configureStore({ raygunMiddleware, ...getDefaultMiddleware({ serializableCheck: { - ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER] - } - }) + ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], + }, + }), ], });