kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Fix scheduled posts
Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1445environments/review-fix-schedu-mflna5/deployments/3617
rodzic
77cf9e9d1e
commit
6b8be7af3c
|
@ -22,7 +22,6 @@ interface IScheduledStatus {
|
||||||
const ScheduledStatus: React.FC<IScheduledStatus> = ({ statusId, ...other }) => {
|
const ScheduledStatus: React.FC<IScheduledStatus> = ({ statusId, ...other }) => {
|
||||||
const status = useAppSelector((state) => {
|
const status = useAppSelector((state) => {
|
||||||
const scheduledStatus = state.scheduled_statuses.get(statusId);
|
const scheduledStatus = state.scheduled_statuses.get(statusId);
|
||||||
|
|
||||||
if (!scheduledStatus) return null;
|
if (!scheduledStatus) return null;
|
||||||
return buildStatus(state, scheduledStatus);
|
return buildStatus(state, scheduledStatus);
|
||||||
}) as StatusEntity | null;
|
}) as StatusEntity | null;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { normalizeAttachment } from 'soapbox/normalizers/attachment';
|
||||||
import { normalizeEmoji } from 'soapbox/normalizers/emoji';
|
import { normalizeEmoji } from 'soapbox/normalizers/emoji';
|
||||||
import { normalizeMention } from 'soapbox/normalizers/mention';
|
import { normalizeMention } from 'soapbox/normalizers/mention';
|
||||||
import { accountSchema, cardSchema, groupSchema, pollSchema, tombstoneSchema } from 'soapbox/schemas';
|
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';
|
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>) => {
|
const parseAccount = (status: ImmutableMap<string, any>) => {
|
||||||
try {
|
try {
|
||||||
const account = accountSchema.parse(status.get('account').toJS());
|
const account = accountSchema.parse(maybeFromJS(status.get('account')));
|
||||||
return status.set('account', account);
|
return status.set('account', account);
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
return status.set('account', null);
|
return status.set('account', null);
|
||||||
|
|
|
@ -26,4 +26,13 @@ export type Normalizer<V, R> = (value: V) => R;
|
||||||
*/
|
*/
|
||||||
export const toSchema = <V, R>(normalizer: Normalizer<V, R>) => {
|
export const toSchema = <V, R>(normalizer: Normalizer<V, R>) => {
|
||||||
return z.custom<V>().transform<R>(normalizer);
|
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;
|
||||||
|
}
|
||||||
};
|
};
|
Ładowanie…
Reference in New Issue