Skip to content

Commit 8d0c9bc

Browse files
committed
in progress
1 parent 0c6e1bf commit 8d0c9bc

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

projects/stream-chat-angular/src/lib/attachment-configuration.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class AttachmentConfigurationService<
228228
sizeRestriction = undefined;
229229
if (displayWarning) {
230230
console.warn(
231-
`Invalid value set for height/max-height and/or max-width for HTML element, this can cause scrolling issues inside the message list, more info https://getstream.io/chat/docs/sdk/angular/components/AttachmentListComponent/#image-and-video-sizing`
231+
`Invalid value set for height/max-height and/or max-width for HTML element, this can cause scrolling issues inside the message list, more info https://getstream.io/chat/docs/sdk/angular/components/AttachmentListComponent/#image-and-video-sizing, attachment URL: ${url}`
232232
);
233233
}
234234
}

projects/stream-chat-angular/src/lib/attachment-list/attachment-list.component.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { ComponentFixture, TestBed } from '@angular/core/testing';
1+
import {
2+
ComponentFixture,
3+
TestBed,
4+
fakeAsync,
5+
tick,
6+
} from '@angular/core/testing';
27
import { By } from '@angular/platform-browser';
38
import { TranslateModule } from '@ngx-translate/core';
49
import { ModalComponent } from '../modal/modal.component';
@@ -46,10 +51,12 @@ describe('AttachmentListComponent', () => {
4651
TestBed.inject(StreamI18nService).setTranslation();
4752
});
4853

49-
beforeEach(() => {
54+
beforeEach(fakeAsync(() => {
5055
fixture = TestBed.createComponent(AttachmentListComponent);
5156
component = fixture.componentInstance;
5257
nativeElement = fixture.nativeElement as HTMLElement;
58+
fixture.detectChanges();
59+
tick();
5360
queryAttachments = () =>
5461
Array.from(
5562
nativeElement.querySelectorAll(
@@ -70,7 +77,6 @@ describe('AttachmentListComponent', () => {
7077
Array.from(nativeElement.querySelectorAll('[data-testclass="url-link"]'));
7178
queryCardImages = () =>
7279
Array.from(nativeElement.querySelectorAll('[data-testclass="card-img"]'));
73-
fixture.detectChanges();
7480
queryActions = () =>
7581
Array.from(
7682
nativeElement.querySelectorAll('[data-testclass="attachment-action"]')
@@ -102,7 +108,7 @@ describe('AttachmentListComponent', () => {
102108
'[data-testclass="video-attachment-parent"]'
103109
)
104110
);
105-
});
111+
}));
106112

107113
it('should display received #attachments ordered', () => {
108114
component.attachments = [];

projects/stream-chat-angular/src/lib/attachment-list/attachment-list.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
AfterViewInit,
3-
ChangeDetectorRef,
43
Component,
54
EventEmitter,
65
HostBinding,
@@ -73,7 +72,6 @@ export class AttachmentListComponent implements OnChanges, AfterViewInit {
7372
public readonly customTemplatesService: CustomTemplatesService,
7473
private channelService: ChannelService,
7574
private attachmentConfigurationService: AttachmentConfigurationService,
76-
private cdRef: ChangeDetectorRef,
7775
themeService: ThemeService
7876
) {
7977
this.themeVersion = themeService.themeVersion;
@@ -99,8 +97,10 @@ export class AttachmentListComponent implements OnChanges, AfterViewInit {
9997
}
10098

10199
ngAfterViewInit(): void {
102-
this.isInited = true;
103-
this.cdRef.detectChanges();
100+
// Wait next tick to make sure CSS rules are properly applied
101+
setTimeout(() => {
102+
this.isInited = true;
103+
}, 0);
104104
}
105105

106106
trackByUrl(_: number, attachment: Attachment) {

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,16 @@ export class MessageListComponent
178178
} else {
179179
this.lastReadMessageId = undefined;
180180
}
181+
this.cdRef.detectChanges();
181182
}
182183
const capabilites = channel?.data?.own_capabilities as string[];
183-
if (capabilites) {
184-
this.enabledMessageActions = capabilites;
184+
const capabilitesString = [...(capabilites || [])].sort().join('');
185+
const enabledActionsString = [...(this.enabledMessageActions || [])]
186+
.sort()
187+
.join('');
188+
if (capabilitesString !== enabledActionsString) {
189+
this.enabledMessageActions = capabilites || [];
190+
this.cdRef.detectChanges();
185191
}
186192
this.newMessageSubscription?.unsubscribe();
187193
if (channel) {
@@ -201,7 +207,6 @@ export class MessageListComponent
201207
});
202208
});
203209
}
204-
this.cdRef.detectChanges();
205210
})
206211
);
207212
this.subscriptions.push(
@@ -700,6 +705,7 @@ export class MessageListComponent
700705
if (this.isUserScrolled) {
701706
this.unreadMessageCount++;
702707
}
708+
this.cdRef.detectChanges();
703709
}
704710
}
705711

0 commit comments

Comments
 (0)