bigbuffet-rw/app/soapbox/features/scheduled_statuses/builder.tsx
marcin mikołajczak 73c4457f28 Scheduled statuses: TypeScript, fix styles
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-05-23 21:14:42 +02:00

31 lines
1.2 KiB
TypeScript

import { Map as ImmutableMap } from 'immutable';
import { normalizeStatus } from 'soapbox/normalizers/status';
import { calculateStatus } from 'soapbox/reducers/statuses';
import { makeGetAccount } from 'soapbox/selectors';
import { RootState } from 'soapbox/store';
export const buildStatus = (state: RootState, scheduledStatus: ImmutableMap<string, any>) => {
const getAccount = makeGetAccount();
const me = state.me as string;
const params = scheduledStatus.get('params');
const account = getAccount(state, me);
const status = ImmutableMap({
account,
content: params.get('text', '').replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
created_at: params.get('scheduled_at'),
id: scheduledStatus.get('id'),
in_reply_to_id: params.get('in_reply_to_id'),
media_attachments: scheduledStatus.get('media_attachments'),
poll: params.get('poll'),
sensitive: params.get('sensitive'),
uri: `/scheduled_statuses/${scheduledStatus.get('id')}`,
url: `/scheduled_statuses/${scheduledStatus.get('id')}`,
visibility: params.get('visibility'),
});
return calculateStatus(normalizeStatus(status));
};