@@ -3,7 +3,15 @@ import type { IntlShape } from 'react-intl';
3
3
import type { DangerouslyImpreciseStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet' ;
4
4
5
5
import type { SubsetProperties } from './generics' ;
6
- import type { Auth , Topic , Message , ReactionType , UserId } from './api/apiTypes' ;
6
+ import type {
7
+ Auth ,
8
+ Topic ,
9
+ Message ,
10
+ PmMessage ,
11
+ StreamMessage ,
12
+ ReactionType ,
13
+ UserId ,
14
+ } from './api/apiTypes' ;
7
15
import type { ZulipVersion } from './utils/zulipVersion' ;
8
16
import type { PmKeyUsers } from './utils/recipient' ;
9
17
@@ -145,27 +153,10 @@ export type TopicExtended = {|
145
153
| } ;
146
154
147
155
/**
148
- * A message we're in the process of sending.
149
- *
150
- * We use these objects for two purposes:
151
- *
152
- * (a) They make up the queue of messages the user has asked us to send, and
153
- * which we'll retry sending if initial attempts fail. See
154
- * `trySendMessages`.
155
- *
156
- * (b) We show them immediately in the message list, even before we've
157
- * successfully gotten them to the server (but with an activity
158
- * indicator to show we're still working on them.)
159
- *
160
- * Even after (a) is complete for a given message, we still need the
161
- * `Outbox` object for the sake of (b), until we hear an `EVENT_NEW_MESSAGE`
162
- * event from the server that lets us replace it with the corresponding
163
- * `Message` object.
164
- *
165
- * This type most often appears in the union `Message | Outbox`, and so its
166
- * properties are deliberately similar to those of `Message`.
156
+ * Properties in common among the two different flavors of a
157
+ * `Outbox`: `PmOutbox` and `StreamOutbox`.
167
158
*/
168
- export type Outbox = $ReadOnly < { |
159
+ export type OutboxBase = $ReadOnly < { |
169
160
/** Used for distinguishing from a `Message` object. */
170
161
isOutbox : true ,
171
162
@@ -184,6 +175,8 @@ export type Outbox = $ReadOnly<{|
184
175
185
176
/* eslint-disable flowtype/generic-spacing */
186
177
...SubsetProperties <
178
+ // Could use `MessageBase` here, but Flow would complain anyway if
179
+ // we tried to put something that's not in `MessageBase` below.
187
180
Message ,
188
181
{ |
189
182
avatar_url : mixed ,
@@ -201,6 +194,41 @@ export type Outbox = $ReadOnly<{|
201
194
> ,
202
195
| } > ;
203
196
197
+ export type PmOutbox = { |
198
+ ...OutboxBase ,
199
+
200
+ ...SubsetProperties < PmMessage , { || } > ,
201
+ | } ;
202
+
203
+ export type StreamOutbox = { |
204
+ ...OutboxBase ,
205
+
206
+ ...SubsetProperties < StreamMessage , { || } > ,
207
+ | } ;
208
+
209
+ /**
210
+ * A message we're in the process of sending.
211
+ *
212
+ * We use these objects for two purposes:
213
+ *
214
+ * (a) They make up the queue of messages the user has asked us to send, and
215
+ * which we'll retry sending if initial attempts fail. See
216
+ * `trySendMessages`.
217
+ *
218
+ * (b) We show them immediately in the message list, even before we've
219
+ * successfully gotten them to the server (but with an activity
220
+ * indicator to show we're still working on them.)
221
+ *
222
+ * Even after (a) is complete for a given message, we still need the
223
+ * `Outbox` object for the sake of (b), until we hear an `EVENT_NEW_MESSAGE`
224
+ * event from the server that lets us replace it with the corresponding
225
+ * `Message` object.
226
+ *
227
+ * This type most often appears in the union `Message | Outbox`, and so its
228
+ * properties are deliberately similar to those of `Message`.
229
+ */
230
+ export type Outbox = PmOutbox | StreamOutbox ;
231
+
204
232
/**
205
233
* MessageLike: Imprecise alternative to `Message | Outbox`.
206
234
*
0 commit comments