Skip to content

Commit cd5397a

Browse files
committed
Fix integration issue
1 parent 808a19d commit cd5397a

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

projects/stream-chat-angular/src/lib/message-input/message-input.component.spec.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,11 +1364,10 @@ describe('MessageInputComponent', () => {
13641364
const channel = mockActiveChannel$.getValue();
13651365
fixture.detectChanges();
13661366
component.loadDraft({
1367-
channel: { cid: `not${channel.cid}` } as any as ChannelResponse,
13681367
message: {
13691368
text: 'Hello, world!',
13701369
} as any as DraftMessage,
1371-
channel_cid: 'messaging:123',
1370+
channel_cid: `not${channel.cid}`,
13721371
created_at: new Date().toISOString(),
13731372
});
13741373
fixture.detectChanges();
@@ -1382,12 +1381,11 @@ describe('MessageInputComponent', () => {
13821381
mockActiveParentMessageId$.next(parentMessageId);
13831382
fixture.detectChanges();
13841383
component.loadDraft({
1385-
channel: { cid: `not${channel.cid}` } as any as ChannelResponse,
13861384
message: {
13871385
text: 'Hello, world!',
13881386
parent_id: 'not' + parentMessageId,
13891387
} as any as DraftMessage,
1390-
channel_cid: 'messaging:123',
1388+
channel_cid: `not${channel.cid}`,
13911389
created_at: new Date().toISOString(),
13921390
});
13931391
fixture.detectChanges();
@@ -1403,11 +1401,10 @@ describe('MessageInputComponent', () => {
14031401
component.ngOnChanges({ message: {} as any as SimpleChange });
14041402
fixture.detectChanges();
14051403
component.loadDraft({
1406-
channel: { cid: channel.cid } as any as ChannelResponse,
14071404
message: {
14081405
text: 'Hello, world!',
14091406
} as any as DraftMessage,
1410-
channel_cid: 'messaging:123',
1407+
channel_cid: channel.cid,
14111408
created_at: new Date().toISOString(),
14121409
});
14131410
fixture.detectChanges();
@@ -1422,11 +1419,10 @@ describe('MessageInputComponent', () => {
14221419
selectMessageToQuoteSpy.calls.reset();
14231420

14241421
component.loadDraft({
1425-
channel: { cid: channel.cid } as any as ChannelResponse,
14261422
message: {
14271423
text: 'Hello, world!',
14281424
} as any as DraftMessage,
1429-
channel_cid: 'messaging:123',
1425+
channel_cid: channel.cid,
14301426
created_at: new Date().toISOString(),
14311427
quoted_message: mockQuotedMessage as any as MessageResponse,
14321428
});
@@ -1442,11 +1438,10 @@ describe('MessageInputComponent', () => {
14421438
const channel = mockActiveChannel$.getValue();
14431439

14441440
component.loadDraft({
1445-
channel: { cid: channel.cid } as any as ChannelResponse,
14461441
message: {
14471442
text: 'Hello, world!',
14481443
} as any as DraftMessage,
1449-
channel_cid: 'messaging:123',
1444+
channel_cid: channel.cid,
14501445
created_at: new Date().toISOString(),
14511446
quoted_message: undefined,
14521447
});
@@ -1458,14 +1453,13 @@ describe('MessageInputComponent', () => {
14581453
it(`should set all fields from draft`, () => {
14591454
const channel = mockActiveChannel$.getValue();
14601455
const draft = {
1461-
channel: { cid: channel.cid } as any as ChannelResponse,
14621456
message: {
14631457
text: 'Hello, world!',
14641458
mentioned_users: ['user1', 'user2'],
14651459
poll_id: 'poll1',
14661460
attachments: [{ type: 'file', url: 'url' }],
14671461
} as any as DraftMessage,
1468-
channel_cid: 'messaging:123',
1462+
channel_cid: channel.cid,
14691463
created_at: new Date().toISOString(),
14701464
};
14711465
attachmentService.createFromAttachments.calls.reset();
@@ -1497,14 +1491,13 @@ describe('MessageInputComponent', () => {
14971491
]);
14981492
});
14991493
const draft = {
1500-
channel: { cid: channel.cid } as any as ChannelResponse,
15011494
message: {
15021495
text: 'Hello, world!',
15031496
mentioned_users: ['user1', 'user2'],
15041497
poll_id: 'poll1',
15051498
attachments: [{ type: 'file', url: 'url' }],
15061499
} as any as DraftMessage,
1507-
channel_cid: 'messaging:123',
1500+
channel_cid: channel.cid,
15081501
created_at: new Date().toISOString(),
15091502
};
15101503
const spy = jasmine.createSpy();

projects/stream-chat-angular/src/lib/message-input/message-input.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export class MessageInputComponent
248248
);
249249
this.subscriptions.push(
250250
this.channelService.channelSwitchState$.subscribe((state) => {
251+
console.log('channelSwitchState', state);
251252
this.isChannelChangeResetInProgress = state === 'start';
252253
})
253254
);
@@ -654,23 +655,26 @@ export class MessageInputComponent
654655
* - If a thread message is loaded, and the input isn't in thread mode or parent ids don't match, the draft is ignored.
655656
*/
656657
loadDraft(draft: DraftResponse) {
658+
console.log('input load draft', draft);
657659
if (
658-
this.channel?.cid !== draft.channel?.cid ||
660+
this.channel?.cid !== draft.channel_cid ||
659661
draft?.message?.parent_id !== this.parentMessageId ||
660662
this.isUpdate
661663
) {
662664
return;
663665
}
664666
this.isLoadingDraft = true;
665-
this.channelService.selectMessageToQuote(draft.quoted_message);
666667

667668
this.textareaValue = draft.message?.text || '';
668669
this.mentionedUsers =
669670
draft?.message?.mentioned_users?.map((id) => ({ id })) || [];
670671
this.pollId = draft?.message?.poll_id;
672+
this.attachmentService.resetAttachmentUploads();
671673
this.attachmentService.createFromAttachments(
672674
draft?.message?.attachments || []
673675
);
676+
console.log('textareaValue', this.textareaValue);
677+
this.channelService.selectMessageToQuote(draft.quoted_message);
674678
this.isLoadingDraft = false;
675679
}
676680

0 commit comments

Comments
 (0)