From 6b8be7af3c09e01c3ed5cb8b5d06bee26addac50 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 17 Jul 2023 10:19:27 -0500 Subject: [PATCH 1/2] Fix scheduled posts Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1445 --- .../scheduled-statuses/components/scheduled-status.tsx | 1 - app/soapbox/normalizers/status.ts | 3 ++- app/soapbox/utils/normalizers.ts | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/soapbox/features/scheduled-statuses/components/scheduled-status.tsx b/app/soapbox/features/scheduled-statuses/components/scheduled-status.tsx index e7e0ab697..11760b05a 100644 --- a/app/soapbox/features/scheduled-statuses/components/scheduled-status.tsx +++ b/app/soapbox/features/scheduled-statuses/components/scheduled-status.tsx @@ -22,7 +22,6 @@ interface IScheduledStatus { const ScheduledStatus: React.FC = ({ statusId, ...other }) => { const status = useAppSelector((state) => { const scheduledStatus = state.scheduled_statuses.get(statusId); - if (!scheduledStatus) return null; return buildStatus(state, scheduledStatus); }) as StatusEntity | null; diff --git a/app/soapbox/normalizers/status.ts b/app/soapbox/normalizers/status.ts index fae88470a..23601f248 100644 --- a/app/soapbox/normalizers/status.ts +++ b/app/soapbox/normalizers/status.ts @@ -14,6 +14,7 @@ import { normalizeAttachment } from 'soapbox/normalizers/attachment'; import { normalizeEmoji } from 'soapbox/normalizers/emoji'; import { normalizeMention } from 'soapbox/normalizers/mention'; import { accountSchema, cardSchema, groupSchema, pollSchema, tombstoneSchema } from 'soapbox/schemas'; +import { maybeFromJS } from 'soapbox/utils/normalizers'; import type { Account, Attachment, Card, Emoji, Group, Mention, Poll, EmbeddedEntity } from 'soapbox/types/entities'; @@ -245,7 +246,7 @@ const normalizeDislikes = (status: ImmutableMap) => { const parseAccount = (status: ImmutableMap) => { try { - const account = accountSchema.parse(status.get('account').toJS()); + const account = accountSchema.parse(maybeFromJS(status.get('account'))); return status.set('account', account); } catch (_e) { return status.set('account', null); diff --git a/app/soapbox/utils/normalizers.ts b/app/soapbox/utils/normalizers.ts index 64638dd29..343b1103b 100644 --- a/app/soapbox/utils/normalizers.ts +++ b/app/soapbox/utils/normalizers.ts @@ -26,4 +26,13 @@ export type Normalizer = (value: V) => R; */ export const toSchema = (normalizer: Normalizer) => { return z.custom().transform(normalizer); +}; + +/** Legacy normalizer transition helper function. */ +export const maybeFromJS = (value: any): unknown => { + if ('toJS' in value) { + return value.toJS(); + } else { + return value; + } }; \ No newline at end of file From 59ee3b102d56327d6bc2ad0ade587fbad40d5e3c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 17 Jul 2023 10:55:08 -0500 Subject: [PATCH 2/2] Fix FE_SUBDIRECTORY lint error --- webpack/shared.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/shared.ts b/webpack/shared.ts index 41ad28773..3d71bfa79 100644 --- a/webpack/shared.ts +++ b/webpack/shared.ts @@ -58,7 +58,7 @@ const configuration: Configuration = { chunkFilename: 'packs/js/[name].chunk.js', hotUpdateChunkFilename: 'packs/js/[id].hot-update.js', path: output.path, - publicPath: process.env.FE_SUBDIRECTORY || '/', + publicPath: FE_SUBDIRECTORY || '/', }, optimization: {