Use Immutable Record
for accounts in Redux state (#26559)
This commit is contained in:
parent
9d799d40ba
commit
3bf2a7296e
65 changed files with 765 additions and 662 deletions
29
app/javascript/mastodon/models/relationship.ts
Normal file
29
app/javascript/mastodon/models/relationship.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import type { RecordOf } from 'immutable';
|
||||
import { Record } from 'immutable';
|
||||
|
||||
import type { ApiRelationshipJSON } from 'mastodon/api_types/relationships';
|
||||
|
||||
type RelationshipShape = Required<ApiRelationshipJSON>; // no changes from server shape
|
||||
export type Relationship = RecordOf<RelationshipShape>;
|
||||
|
||||
const RelationshipFactory = Record<RelationshipShape>({
|
||||
blocked_by: false,
|
||||
blocking: false,
|
||||
domain_blocking: false,
|
||||
endorsed: false,
|
||||
followed_by: false,
|
||||
following: false,
|
||||
id: '',
|
||||
languages: null,
|
||||
muting_notifications: false,
|
||||
muting: false,
|
||||
note: '',
|
||||
notifying: false,
|
||||
requested_by: false,
|
||||
requested: false,
|
||||
showing_reblogs: false,
|
||||
});
|
||||
|
||||
export function createRelationship(attributes: Partial<RelationshipShape>) {
|
||||
return RelationshipFactory(attributes);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue