@@ -230,30 +230,21 @@ import type {
230
230
import { ChannelManager } from './channel_manager' ;
231
231
import { NotificationManager } from './notifications' ;
232
232
import { StateStore } from './store' ;
233
- import type { MessageComposerOptions } from './messageComposer' ;
234
- import { MessageComposer } from './messageComposer' ;
233
+ import type { MessageComposer } from './messageComposer' ;
235
234
236
235
function isString ( x : unknown ) : x is string {
237
236
return typeof x === 'string' || x instanceof String ;
238
237
}
239
238
240
- type MessageComposerDefine = ( {
241
- constructorParameters,
242
- } : {
243
- constructorParameters : MessageComposerOptions ;
244
- } ) => MessageComposer ;
239
+ type MessageComposerTearDownFunction = ( ) => void ;
245
240
246
- type MessageComposerApplyModifications = ( {
241
+ type MessageComposerSetupFunction = ( {
247
242
composer,
248
243
} : {
249
244
composer : MessageComposer ;
250
- } ) => void | ( ( ) => void ) ;
245
+ } ) => void | MessageComposerTearDownFunction ;
251
246
252
- // TODO: maybe template modifications
253
- // { template1: { applyModifications... }, template2: {applyModifications} }
254
- // new MessageComposer({ channel, modificationTemplate: 'template1' })
255
247
type MessageComposerSetupState = {
256
- define : MessageComposerDefine ;
257
248
/**
258
249
* Each `MessageComposer` runs this function each time its signature changes or
259
250
* whenever you run `MessageComposer.registerSubscriptions`. Function returned
@@ -262,12 +253,7 @@ type MessageComposerSetupState = {
262
253
* modified parts is the general way to go but if your setup gets a bit
263
254
* complicated, feel free to restore the whole composer with `MessageComposer.restore`.
264
255
*/
265
- applyModifications : MessageComposerApplyModifications | null ;
266
- } ;
267
-
268
- const INITIAL_MESSAGE_COMPOSER_SETUP_STATE : MessageComposerSetupState = {
269
- define : ( { constructorParameters } ) => new MessageComposer ( constructorParameters ) ,
270
- applyModifications : null ,
256
+ setupFunction : MessageComposerSetupFunction | null ;
271
257
} ;
272
258
273
259
export class StreamChat {
@@ -325,8 +311,12 @@ export class StreamChat {
325
311
sdkIdentifier ?: SdkIdentifier ;
326
312
deviceIdentifier ?: DeviceIdentifier ;
327
313
private nextRequestAbortController : AbortController | null = null ;
328
- public _messageComposerSetupState : StateStore < MessageComposerSetupState > =
329
- new StateStore ( INITIAL_MESSAGE_COMPOSER_SETUP_STATE ) ;
314
+ /**
315
+ * @private
316
+ */
317
+ _messageComposerSetupState = new StateStore < MessageComposerSetupState > ( {
318
+ setupFunction : null ,
319
+ } ) ;
330
320
331
321
/**
332
322
* Initialize a client
@@ -4397,13 +4387,9 @@ export class StreamChat {
4397
4387
return await this . post < QueryDraftsResponse > ( this . baseURL + '/drafts/query' , payload ) ;
4398
4388
}
4399
4389
4400
- // TODO: this might not be needed
4401
- public createMessageComposer : MessageComposerDefine = ( setup ) =>
4402
- this . _messageComposerSetupState . getLatestValue ( ) . define ( setup ) ;
4403
-
4404
- public setMessageComposerApplyModifications = (
4405
- applyModifications : MessageComposerSetupState [ 'applyModifications' ] ,
4390
+ public setMessageComposerSetupFunction = (
4391
+ setupFunction : MessageComposerSetupState [ 'setupFunction' ] ,
4406
4392
) => {
4407
- this . _messageComposerSetupState . partialNext ( { applyModifications } ) ;
4393
+ this . _messageComposerSetupState . partialNext ( { setupFunction } ) ;
4408
4394
} ;
4409
4395
}
0 commit comments