From 44a4116a750b122c048d4c5c6eafd12971b075ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 14 Nov 2024 21:18:56 +0100 Subject: [PATCH] pl-fe: wip migrate pl-fe config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-fe/src/actions/pl-fe.ts | 9 +- packages/pl-fe/src/actions/timelines.ts | 2 +- packages/pl-fe/src/components/navlinks.tsx | 4 +- .../src/components/site-error-boundary.tsx | 12 +- packages/pl-fe/src/features/about/index.tsx | 6 +- .../components/crypto-donate-panel.tsx | 6 +- .../crypto-donate/components/site-wallet.tsx | 2 +- .../components/crypto-address-input.tsx | 2 +- .../components/footer-link-input.tsx | 2 +- .../components/promo-panel-input.tsx | 2 +- .../pl-fe-config/components/site-preview.tsx | 5 +- .../pl-fe/src/features/pl-fe-config/index.tsx | 15 +- .../pl-fe/src/features/theme-editor/index.tsx | 21 +- .../report-modal/steps/confirmation-step.tsx | 6 +- .../ui/components/panels/promo-panel.tsx | 6 +- .../features/ui/components/pending-status.tsx | 2 +- packages/pl-fe/src/features/ui/index.tsx | 2 +- .../ui/util/pending-status-builder.ts | 17 +- packages/pl-fe/src/hooks/use-pl-fe-config.ts | 4 +- packages/pl-fe/src/init/pl-fe-head.tsx | 5 +- packages/pl-fe/src/jest/test-helpers.tsx | 3 +- packages/pl-fe/src/layouts/home-layout.tsx | 4 +- .../src/normalizers/pl-fe/pl-fe-config.ts | 291 +++++++----------- .../pl-fe/src/reducers/pending-statuses.ts | 52 +++- packages/pl-fe/src/types/colors.ts | 2 +- packages/pl-fe/src/types/pl-fe.ts | 20 +- packages/pl-fe/src/utils/tailwind.ts | 35 ++- packages/pl-fe/src/utils/theme.ts | 4 +- 28 files changed, 237 insertions(+), 304 deletions(-) diff --git a/packages/pl-fe/src/actions/pl-fe.ts b/packages/pl-fe/src/actions/pl-fe.ts index 80b0ea886..6a81db1d9 100644 --- a/packages/pl-fe/src/actions/pl-fe.ts +++ b/packages/pl-fe/src/actions/pl-fe.ts @@ -1,7 +1,8 @@ import { createSelector } from 'reselect'; +import * as v from 'valibot'; import { getHost } from 'pl-fe/actions/instance'; -import { normalizePlFeConfig } from 'pl-fe/normalizers/pl-fe/pl-fe-config'; +import { plFeConfigSchema } from 'pl-fe/normalizers/pl-fe/pl-fe-config'; import KVStore from 'pl-fe/storage/kv-store'; import { useSettingsStore } from 'pl-fe/stores/settings'; @@ -17,10 +18,8 @@ const PLFE_CONFIG_REMEMBER_SUCCESS = 'PLFE_CONFIG_REMEMBER_SUCCESS' as const; const getPlFeConfig = createSelector([ (state: RootState) => state.plfe, -], (plfe) => { - // Do some additional normalization with the state - return normalizePlFeConfig(plfe); -}); +// Do some additional normalization with the state +], (plfe) => v.parse(plFeConfigSchema, plfe)); const rememberPlFeConfig = (host: string | null) => (dispatch: AppDispatch) => { diff --git a/packages/pl-fe/src/actions/timelines.ts b/packages/pl-fe/src/actions/timelines.ts index 287c3425f..dfc5f3a12 100644 --- a/packages/pl-fe/src/actions/timelines.ts +++ b/packages/pl-fe/src/actions/timelines.ts @@ -28,7 +28,7 @@ const processTimelineUpdate = (timeline: string, status: BaseStatus) => (dispatch: AppDispatch, getState: () => RootState) => { const me = getState().me; const ownStatus = status.account?.id === me; - const hasPendingStatuses = !getState().pending_statuses.isEmpty(); + const hasPendingStatuses = !!getState().pending_statuses.length; const columnSettings = useSettingsStore.getState().settings.timelines[timeline]; const shouldSkipQueue = shouldFilter({ diff --git a/packages/pl-fe/src/components/navlinks.tsx b/packages/pl-fe/src/components/navlinks.tsx index ee84fd150..8a49c5ef0 100644 --- a/packages/pl-fe/src/components/navlinks.tsx +++ b/packages/pl-fe/src/components/navlinks.tsx @@ -16,7 +16,7 @@ const Navlinks: React.FC = ({ type }) => { return (