Merge branch 'fix-scheduled-posts' into 'develop'

Fix scheduled posts

Closes #1445

See merge request soapbox-pub/soapbox!2606
This commit is contained in:
Alex Gleason 2023-07-17 16:13:00 +00:00
commit 36083fe1b8
4 changed files with 12 additions and 3 deletions

View file

@ -22,7 +22,6 @@ interface IScheduledStatus {
const ScheduledStatus: React.FC<IScheduledStatus> = ({ statusId, ...other }) => {
const status = useAppSelector((state) => {
const scheduledStatus = state.scheduled_statuses.get(statusId);
if (!scheduledStatus) return null;
return buildStatus(state, scheduledStatus);
}) as StatusEntity | null;

View file

@ -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<string, any>) => {
const parseAccount = (status: ImmutableMap<string, any>) => {
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);

View file

@ -27,3 +27,12 @@ export type Normalizer<V, R> = (value: V) => R;
export const toSchema = <V, R>(normalizer: Normalizer<V, R>) => {
return z.custom<V>().transform<R>(normalizer);
};
/** Legacy normalizer transition helper function. */
export const maybeFromJS = (value: any): unknown => {
if ('toJS' in value) {
return value.toJS();
} else {
return value;
}
};

View file

@ -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: {