Fix scheduled posts
Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1445
This commit is contained in:
parent
77cf9e9d1e
commit
6b8be7af3c
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue