Changeset View
Changeset View
Standalone View
Standalone View
lib/types/user-types.js
// @flow | // @flow | ||||
import t, { type TInterface } from 'tcomb'; | import t, { type TInterface, type TDict } from 'tcomb'; | ||||
import { | import { | ||||
type DefaultNotificationPayload, | type DefaultNotificationPayload, | ||||
defaultNotificationPayloadValidator, | defaultNotificationPayloadValidator, | ||||
} from './account-types.js'; | } from './account-types.js'; | ||||
import { type ClientAvatar, clientAvatarValidator } from './avatar-types.js'; | import { type ClientAvatar, clientAvatarValidator } from './avatar-types.js'; | ||||
import { | import { | ||||
type UserRelationshipStatus, | type UserRelationshipStatus, | ||||
Show All 28 Lines | |||||
}; | }; | ||||
export const userInfoValidator: TInterface<UserInfo> = tShape<UserInfo>({ | export const userInfoValidator: TInterface<UserInfo> = tShape<UserInfo>({ | ||||
id: t.String, | id: t.String, | ||||
username: t.maybe(t.String), | username: t.maybe(t.String), | ||||
relationshipStatus: t.maybe(userRelationshipStatusValidator), | relationshipStatus: t.maybe(userRelationshipStatusValidator), | ||||
avatar: t.maybe(clientAvatarValidator), | avatar: t.maybe(clientAvatarValidator), | ||||
}); | }); | ||||
export type UserInfos = { +[id: string]: UserInfo }; | export type UserInfos = { +[id: string]: UserInfo }; | ||||
export const userInfosValidator: TDict<UserInfos> = t.dict( | |||||
t.String, | |||||
userInfoValidator, | |||||
); | |||||
export type AccountUserInfo = { | export type AccountUserInfo = { | ||||
+id: string, | +id: string, | ||||
+username: string, | +username: string, | ||||
+relationshipStatus?: UserRelationshipStatus, | +relationshipStatus?: UserRelationshipStatus, | ||||
+avatar?: ?ClientAvatar, | +avatar?: ?ClientAvatar, | ||||
}; | }; | ||||
export const accountUserInfoValidator: TInterface<AccountUserInfo> = | export const accountUserInfoValidator: TInterface<AccountUserInfo> = | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |