Reducers: TypeScript
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@@ -17,7 +17,7 @@ import { unescapeHTML } from 'soapbox/utils/html';
|
||||
import { mergeDefined, makeEmojiMap } from 'soapbox/utils/normalizers';
|
||||
|
||||
import type { PatronAccount } from 'soapbox/reducers/patron';
|
||||
import type { Emoji, Field, EmbeddedEntity } from 'soapbox/types/entities';
|
||||
import type { Emoji, Field, EmbeddedEntity, Relationship } from 'soapbox/types/entities';
|
||||
|
||||
// https://docs.joinmastodon.org/entities/account/
|
||||
export const AccountRecord = ImmutableRecord({
|
||||
@@ -61,7 +61,7 @@ export const AccountRecord = ImmutableRecord({
|
||||
note_emojified: '',
|
||||
note_plain: '',
|
||||
patron: null as PatronAccount | null,
|
||||
relationship: ImmutableMap<string, any>(),
|
||||
relationship: null as Relationship | null,
|
||||
should_refetch: false,
|
||||
staff: false,
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ export { ListRecord, normalizeList } from './list';
|
||||
export { MentionRecord, normalizeMention } from './mention';
|
||||
export { NotificationRecord, normalizeNotification } from './notification';
|
||||
export { PollRecord, PollOptionRecord, normalizePoll } from './poll';
|
||||
export { RelationshipRecord, normalizeRelationship } from './relationship';
|
||||
export { StatusRecord, normalizeStatus } from './status';
|
||||
export { StatusEditRecord, normalizeStatusEdit } from './status_edit';
|
||||
|
||||
|
||||
35
app/soapbox/normalizers/relationship.ts
Normal file
35
app/soapbox/normalizers/relationship.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Relationship normalizer:
|
||||
* Converts API relationships into our internal format.
|
||||
* @see {@link https://docs.joinmastodon.org/entities/relationship/}
|
||||
*/
|
||||
import {
|
||||
Map as ImmutableMap,
|
||||
Record as ImmutableRecord,
|
||||
fromJS,
|
||||
} from 'immutable';
|
||||
|
||||
// https://docs.joinmastodon.org/entities/relationship/
|
||||
// https://api.pleroma.social/#operation/AccountController.relationships
|
||||
export const RelationshipRecord = ImmutableRecord({
|
||||
blocked_by: false,
|
||||
blocking: false,
|
||||
domain_blocking: false,
|
||||
endorsed: false,
|
||||
followed_by: false,
|
||||
following: false,
|
||||
id: '',
|
||||
muting: false,
|
||||
muting_notifications: false,
|
||||
note: '',
|
||||
notifying: false,
|
||||
requested: false,
|
||||
showing_reblogs: false,
|
||||
subscribing: false,
|
||||
});
|
||||
|
||||
export const normalizeRelationship = (relationship: Record<string, any>) => {
|
||||
return RelationshipRecord(
|
||||
ImmutableMap(fromJS(relationship)),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user