WIP pl-api migration
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -27,7 +27,7 @@ import EventActionButton from '../components/event-action-button';
|
||||
import EventDate from '../components/event-date';
|
||||
|
||||
import type { Menu as MenuType } from 'soapbox/components/dropdown-menu';
|
||||
import type { Status as StatusEntity } from 'soapbox/normalizers';
|
||||
import type { Status } from 'soapbox/normalizers';
|
||||
|
||||
const messages = defineMessages({
|
||||
bannerHeader: { id: 'event.banner', defaultMessage: 'Event banner' },
|
||||
@ -61,7 +61,7 @@ const messages = defineMessages({
|
||||
});
|
||||
|
||||
interface IEventHeader {
|
||||
status?: StatusEntity;
|
||||
status?: Pick<Status, 'id' | 'account' | 'bookmarked' | 'event' | 'group' | 'pinned' | 'reblog' | 'reblogged' | 'sensitive' | 'uri' | 'url' | 'visibility'>;
|
||||
}
|
||||
|
||||
const EventHeader: React.FC<IEventHeader> = ({ status }) => {
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { statusSchema } from 'pl-api';
|
||||
import { statusSchema, type ScheduledStatus } from 'pl-api';
|
||||
|
||||
import { Entities } from 'soapbox/entity-store/entities';
|
||||
import { normalizeStatus } from 'soapbox/normalizers/status';
|
||||
|
||||
import type { ScheduledStatus } from 'soapbox/reducers/scheduled-statuses';
|
||||
import type { RootState } from 'soapbox/store';
|
||||
|
||||
const buildStatus = (state: RootState, scheduledStatus: ScheduledStatus) => {
|
||||
@ -12,17 +11,18 @@ const buildStatus = (state: RootState, scheduledStatus: ScheduledStatus) => {
|
||||
|
||||
const status = statusSchema.parse({
|
||||
account,
|
||||
content: scheduledStatus.text.replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
|
||||
created_at: scheduledStatus.scheduled_at,
|
||||
content: scheduledStatus.params.text?.replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
|
||||
created_at: scheduledStatus.params.scheduled_at,
|
||||
id: scheduledStatus.id,
|
||||
in_reply_to_id: scheduledStatus.in_reply_to_id,
|
||||
in_reply_to_id: scheduledStatus.params.in_reply_to_id,
|
||||
media_attachments: scheduledStatus.media_attachments,
|
||||
poll: scheduledStatus.poll,
|
||||
sensitive: scheduledStatus.sensitive,
|
||||
poll: scheduledStatus.params.poll,
|
||||
sensitive: scheduledStatus.params.sensitive,
|
||||
uri: `/scheduled_statuses/${scheduledStatus.id}`,
|
||||
url: `/scheduled_statuses/${scheduledStatus.id}`,
|
||||
visibility: scheduledStatus.visibility,
|
||||
visibility: scheduledStatus.params.visibility,
|
||||
});
|
||||
console.log(scheduledStatus.params);
|
||||
|
||||
return normalizeStatus(status);
|
||||
};
|
||||
|
||||
@ -13,8 +13,6 @@ import { buildStatus } from '../builder';
|
||||
|
||||
import ScheduledStatusActionBar from './scheduled-status-action-bar';
|
||||
|
||||
import type { Status as StatusEntity } from 'soapbox/types/entities';
|
||||
|
||||
interface IScheduledStatus {
|
||||
statusId: string;
|
||||
}
|
||||
@ -24,7 +22,7 @@ const ScheduledStatus: React.FC<IScheduledStatus> = ({ statusId, ...other }) =>
|
||||
const scheduledStatus = state.scheduled_statuses.get(statusId);
|
||||
if (!scheduledStatus) return null;
|
||||
return buildStatus(state, scheduledStatus);
|
||||
}) as StatusEntity | null;
|
||||
});
|
||||
|
||||
if (!status) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user