Simplify scheduled/pending status builders
This commit is contained in:
@@ -13,31 +13,13 @@ export const buildStatus = (state, scheduledStatus) => {
|
||||
|
||||
const status = {
|
||||
account,
|
||||
application: null,
|
||||
bookmarked: false,
|
||||
card: null,
|
||||
content: params.get('text', '').replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
|
||||
created_at: params.get('scheduled_at'),
|
||||
emojis: [],
|
||||
favourited: false,
|
||||
favourites_count: 0,
|
||||
id: scheduledStatus.get('id'),
|
||||
in_reply_to_account_id: null,
|
||||
in_reply_to_id: params.get('in_reply_to_id'),
|
||||
language: null,
|
||||
media_attachments: scheduledStatus.get('media_attachments'),
|
||||
mentions: [],
|
||||
muted: false,
|
||||
pinned: false,
|
||||
poll: params.get('poll'),
|
||||
reblog: null,
|
||||
reblogged: false,
|
||||
reblogs_count: 0,
|
||||
replies_count: 0,
|
||||
sensitive: params.get('sensitive'),
|
||||
spoiler_text: '',
|
||||
tags: [],
|
||||
text: null,
|
||||
uri: `/scheduled_statuses/${scheduledStatus.get('id')}`,
|
||||
url: `/scheduled_statuses/${scheduledStatus.get('id')}`,
|
||||
visibility: params.get('visibility'),
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { fromJS } from 'immutable';
|
||||
import { OrderedSet as ImmutableOrderedSet, Map as ImmutableMap } from 'immutable';
|
||||
import {
|
||||
OrderedSet as ImmutableOrderedSet,
|
||||
Map as ImmutableMap,
|
||||
List as ImmutableList,
|
||||
} from 'immutable';
|
||||
|
||||
import { normalizeStatus } from 'soapbox/normalizers/status';
|
||||
import { calculateStatus } from 'soapbox/reducers/statuses';
|
||||
@@ -30,34 +34,14 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => {
|
||||
|
||||
const status = {
|
||||
account,
|
||||
application: null,
|
||||
bookmarked: false,
|
||||
card: null,
|
||||
content: pendingStatus.get('status', '').replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
|
||||
created_at: new Date(),
|
||||
emojis: [],
|
||||
favourited: false,
|
||||
favourites_count: 0,
|
||||
id: `末pending-${idempotencyKey}`,
|
||||
in_reply_to_account_id: null,
|
||||
in_reply_to_id: pendingStatus.get('in_reply_to_id'),
|
||||
language: null,
|
||||
media_attachments: pendingStatus.get('media_ids').map(id => (ImmutableMap({ id }))),
|
||||
media_attachments: pendingStatus.get('media_ids', ImmutableList()).map(id => ImmutableMap({ id })),
|
||||
mentions,
|
||||
muted: false,
|
||||
pinned: false,
|
||||
poll: pendingStatus.get('poll', null),
|
||||
quote: pendingStatus.get('quote_id', null),
|
||||
reblog: null,
|
||||
reblogged: false,
|
||||
reblogs_count: 0,
|
||||
replies_count: 0,
|
||||
sensitive: pendingStatus.get('sensitive', false),
|
||||
spoiler_text: '',
|
||||
tags: [],
|
||||
text: null,
|
||||
uri: '',
|
||||
url: '',
|
||||
visibility: pendingStatus.get('visibility', 'public'),
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,28 @@ import { accountToMention } from 'soapbox/utils/accounts';
|
||||
|
||||
// Some backends can return null, or omit these required fields
|
||||
const baseStatus = ImmutableMap({
|
||||
application: null,
|
||||
bookmarked: false,
|
||||
card: null,
|
||||
created_at: new Date(),
|
||||
emojis: ImmutableList(),
|
||||
spoiler_text: '',
|
||||
favourited: false,
|
||||
favourites_count: 0,
|
||||
in_reply_to_account_id: null,
|
||||
in_reply_to_id: null,
|
||||
language: null,
|
||||
mentions: ImmutableList(),
|
||||
muted: false,
|
||||
pinned: false,
|
||||
reblog: null,
|
||||
reblogged: false,
|
||||
reblogs_count: 0,
|
||||
replies_count: 0,
|
||||
spoiler_text: '',
|
||||
tags: ImmutableList(),
|
||||
uri: '',
|
||||
url: '',
|
||||
visibility: 'public',
|
||||
});
|
||||
|
||||
const mergeDefined = (oldVal, newVal) => oldVal === undefined ? newVal : oldVal;
|
||||
|
||||
Reference in New Issue
Block a user