Changeset View
Changeset View
Standalone View
Standalone View
lib/types/messages/reaction.js
// @flow | // @flow | ||||
import t, { type TInterface } from 'tcomb'; | |||||
import { tID, tNumber, tShape } from '../../utils/validation-utils.js'; | |||||
import { messageTypes } from '../message-types-enum.js'; | |||||
import type { RelativeUserInfo } from '../user-types.js'; | import type { RelativeUserInfo } from '../user-types.js'; | ||||
export type ReactionMessageData = { | export type ReactionMessageData = { | ||||
+type: 19, | +type: 19, | ||||
+localID?: string, // for optimistic creations. included by new clients | +localID?: string, // for optimistic creations. included by new clients | ||||
+threadID: string, | +threadID: string, | ||||
+creatorID: string, | +creatorID: string, | ||||
+time: number, | +time: number, | ||||
+targetMessageID: string, | +targetMessageID: string, | ||||
+reaction: string, | +reaction: string, | ||||
+action: 'add_reaction' | 'remove_reaction', | +action: 'add_reaction' | 'remove_reaction', | ||||
}; | }; | ||||
export type RawReactionMessageInfo = { | export type RawReactionMessageInfo = { | ||||
...ReactionMessageData, | ...ReactionMessageData, | ||||
id?: string, // null if local copy without ID yet | id?: string, // null if local copy without ID yet | ||||
}; | }; | ||||
export const rawReactionMessageInfoValidator: TInterface<RawReactionMessageInfo> = | |||||
tShape<RawReactionMessageInfo>({ | |||||
type: tNumber(messageTypes.REACTION), | |||||
localID: t.maybe(t.String), | |||||
threadID: tID, | |||||
creatorID: t.String, | |||||
time: t.Number, | |||||
targetMessageID: tID, | |||||
reaction: t.String, | |||||
action: t.enums.of(['add_reaction', 'remove_reaction']), | |||||
id: t.maybe(tID), | |||||
}); | |||||
export type ReactionMessageInfo = { | export type ReactionMessageInfo = { | ||||
+type: 19, | +type: 19, | ||||
+id?: string, // null if local copy without ID yet | +id?: string, // null if local copy without ID yet | ||||
+localID?: string, // for optimistic creations | +localID?: string, // for optimistic creations | ||||
+threadID: string, | +threadID: string, | ||||
+creator: RelativeUserInfo, | +creator: RelativeUserInfo, | ||||
+time: number, | +time: number, | ||||
+targetMessageID: string, | +targetMessageID: string, | ||||
+reaction: string, | +reaction: string, | ||||
+action: 'add_reaction' | 'remove_reaction', | +action: 'add_reaction' | 'remove_reaction', | ||||
}; | }; |