Changeset View
Changeset View
Standalone View
Standalone View
lib/types/message-types.js
Show First 20 Lines • Show All 384 Lines • ▼ Show 20 Lines | export type MessageInfo = | ||||
| EditMessageInfo; | | EditMessageInfo; | ||||
export type ThreadMessageInfo = { | export type ThreadMessageInfo = { | ||||
messageIDs: string[], | messageIDs: string[], | ||||
startReached: boolean, | startReached: boolean, | ||||
lastNavigatedTo: number, // millisecond timestamp | lastNavigatedTo: number, // millisecond timestamp | ||||
lastPruned: number, // millisecond timestamp | lastPruned: number, // millisecond timestamp | ||||
}; | }; | ||||
const threadMessageInfoValidator: TInterface<ThreadMessageInfo> = | |||||
tShape<ThreadMessageInfo>({ | |||||
messageIDs: t.list(tID), | |||||
startReached: t.Boolean, | |||||
lastNavigatedTo: t.Number, | |||||
lastPruned: t.Number, | |||||
}); | |||||
// Tracks client-local information about a message that hasn't been assigned an | // Tracks client-local information about a message that hasn't been assigned an | ||||
// ID by the server yet. As soon as the client gets an ack from the server for | // ID by the server yet. As soon as the client gets an ack from the server for | ||||
// this message, it will clear the LocalMessageInfo. | // this message, it will clear the LocalMessageInfo. | ||||
export type LocalMessageInfo = { | export type LocalMessageInfo = { | ||||
+sendFailed?: boolean, | +sendFailed?: boolean, | ||||
}; | }; | ||||
const localMessageInfoValidator: TInterface<LocalMessageInfo> = | |||||
tShape<LocalMessageInfo>({ | |||||
sendFailed: t.maybe(t.Boolean), | |||||
}); | |||||
export type MessageStoreThreads = { | export type MessageStoreThreads = { | ||||
+[threadID: string]: ThreadMessageInfo, | +[threadID: string]: ThreadMessageInfo, | ||||
}; | }; | ||||
const messageStoreThreadsValidator: TDict<MessageStoreThreads> = t.dict( | |||||
tID, | |||||
threadMessageInfoValidator, | |||||
); | |||||
export type MessageStore = { | export type MessageStore = { | ||||
+messages: { +[id: string]: RawMessageInfo }, | +messages: { +[id: string]: RawMessageInfo }, | ||||
+threads: MessageStoreThreads, | +threads: MessageStoreThreads, | ||||
+local: { +[id: string]: LocalMessageInfo }, | +local: { +[id: string]: LocalMessageInfo }, | ||||
+currentAsOf: number, | +currentAsOf: number, | ||||
}; | }; | ||||
export const messageStoreValidator: TInterface<MessageStore> = | |||||
tShape<MessageStore>({ | |||||
messages: t.dict(tID, rawMessageInfoValidator), | |||||
threads: messageStoreThreadsValidator, | |||||
local: t.dict(t.String, localMessageInfoValidator), | |||||
currentAsOf: t.Number, | |||||
}); | |||||
// MessageStore messages ops | // MessageStore messages ops | ||||
export type RemoveMessageOperation = { | export type RemoveMessageOperation = { | ||||
+type: 'remove', | +type: 'remove', | ||||
+payload: { +ids: $ReadOnlyArray<string> }, | +payload: { +ids: $ReadOnlyArray<string> }, | ||||
}; | }; | ||||
export type RemoveMessagesForThreadsOperation = { | export type RemoveMessagesForThreadsOperation = { | ||||
▲ Show 20 Lines • Show All 279 Lines • Show Last 20 Lines |