Skip to content

Commit 8c1fb7f

Browse files
committed
in progress
1 parent a473196 commit 8c1fb7f

File tree

48 files changed

+673
-707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+673
-707
lines changed

package-lock.json

Lines changed: 159 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"pretty-bytes": "^6.1.1",
119119
"rxjs": "~7.4.0",
120120
"starwars-names": "^1.6.0",
121-
"stream-chat": "^8.44.0",
121+
"stream-chat": "9.0.0-rc.3",
122122
"ts-node": "^10.9.2",
123123
"tslib": "^2.3.0",
124124
"uuid": "^9.0.1",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'stream-chat';
2+
3+
declare module 'stream-chat' {
4+
interface CustomUserData {
5+
image?: string;
6+
}
7+
8+
interface CustomAttachmentData {
9+
/**
10+
* @deprecated Please use `image_url` instead
11+
*/
12+
img_url?: string;
13+
}
14+
}

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,33 @@ import {
1313
@Injectable({
1414
providedIn: 'root',
1515
})
16-
export class AttachmentConfigurationService<
17-
T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
18-
> {
16+
export class AttachmentConfigurationService {
1917
/**
2018
* A custom handler can be provided to override the default image attachment (images uploaded from files) configuration. By default the SDK uses fixed image height (a size that's known before image is loaded), if you override that with dynamic image height (for example: height: 100%) the scrolling logic inside the message list can break.
2119
*/
2220
customImageAttachmentConfigurationHandler?: (
23-
a: Attachment<T>,
21+
a: Attachment,
2422
type: 'gallery' | 'single' | 'carousel',
2523
containerElement: HTMLElement
2624
) => ImageAttachmentConfiguration;
2725
/**
2826
* A custom handler can be provided to override the default video attachment (videos uploaded from files) configuration. By default the SDK uses fixed height (a size that's known before video is loaded), if you override that with dynamic height (for example: height: 100%) the scrolling logic inside the message list can break.
2927
*/
3028
customVideoAttachmentConfigurationHandler?: (
31-
a: Attachment<T>,
29+
a: Attachment,
3230
containerElement: HTMLElement
3331
) => VideoAttachmentConfiguration;
3432
/**
3533
* A custom handler can be provided to override the default giphy attachment (GIFs sent with the /giphy command) configuration. By default the SDK uses fixed height (a size that's known before the GIF is loaded), if you override that with dynamic height (for example: height: 100%) the scrolling logic inside the message list can break.
3634
*/
3735
customGiphyAttachmentConfigurationHandler?: (
38-
a: Attachment<T>
36+
a: Attachment
3937
) => AttachmentConfigration;
4038
/**
4139
* A custom handler can be provided to override the default scraped image attachment (images found in links inside messages) configuration. By default the SDK uses fixed height (a size that's known before image is loaded), if you override that with dynamic height (for example: height: 100%) the scrolling logic inside the message list can break.
4240
*/
4341
customScrapedImageAttachmentConfigurationHandler?: (
44-
a: Attachment<T>
42+
a: Attachment
4543
) => AttachmentConfigration;
4644
/**
4745
* You can turn on/off thumbnail generation for video attachments
@@ -55,7 +53,7 @@ export class AttachmentConfigurationService<
5553
* @param element The default resizing logics reads the height/max-height and max-width propperties of this element and reduces file size based on the given values. File size reduction is done by Stream's CDN.
5654
*/
5755
getImageAttachmentConfiguration(
58-
attachment: Attachment<T>,
56+
attachment: Attachment,
5957
location: 'gallery' | 'single' | 'carousel',
6058
element: HTMLElement
6159
): ImageAttachmentConfiguration {
@@ -121,7 +119,7 @@ export class AttachmentConfigurationService<
121119
* @param element The default resizing logics reads the height/max-height and max-width propperties of this element and reduces file size based on the given values. File size reduction is done by Stream's CDN.
122120
*/
123121
getVideoAttachmentConfiguration(
124-
attachment: Attachment<T>,
122+
attachment: Attachment,
125123
element: HTMLElement
126124
): VideoAttachmentConfiguration {
127125
if (this.customVideoAttachmentConfigurationHandler) {
@@ -178,7 +176,7 @@ export class AttachmentConfigurationService<
178176
* @param attachment The attachment to configure
179177
*/
180178
getGiphyAttachmentConfiguration(
181-
attachment: Attachment<T>
179+
attachment: Attachment
182180
): AttachmentConfigration {
183181
if (this.customGiphyAttachmentConfigurationHandler) {
184182
return this.customGiphyAttachmentConfigurationHandler(attachment);
@@ -198,7 +196,7 @@ export class AttachmentConfigurationService<
198196
* @param attachment The attachment to configure
199197
*/
200198
getScrapedImageAttachmentConfiguration(
201-
attachment: Attachment<T>
199+
attachment: Attachment
202200
): AttachmentConfigration {
203201
if (this.customScrapedImageAttachmentConfigurationHandler) {
204202
return this.customScrapedImageAttachmentConfigurationHandler(attachment);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ describe('AttachmentListComponent', () => {
380380
frames: '6',
381381
},
382382
},
383-
} as any as Attachment<DefaultStreamChatGenerics>;
383+
} as any as Attachment;
384384
component.attachments = [attachment];
385385
component.ngOnChanges({ attachments: {} as SimpleChange });
386386
fixture.detectChanges();
@@ -435,7 +435,7 @@ describe('AttachmentListComponent', () => {
435435
frames: '6',
436436
},
437437
},
438-
} as any as Attachment<DefaultStreamChatGenerics>;
438+
} as any as Attachment;
439439
component.messageId = 'message-id';
440440
component.attachments = [attachment];
441441
component.parentMessageId = 'parent-id';

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ export class AttachmentListComponent implements OnChanges, OnInit, OnDestroy {
4949
/**
5050
* The attachments to display
5151
*/
52-
@Input() attachments: Attachment<DefaultStreamChatGenerics>[] = [];
52+
@Input() attachments: Attachment[] = [];
5353
/**
5454
* Emits the state of the image carousel window
5555
*/
5656
@Output() readonly imageModalStateChange = new EventEmitter<
5757
'opened' | 'closed'
5858
>();
5959
@HostBinding() class = 'str-chat__attachment-list-angular-host';
60-
orderedAttachments: Attachment<DefaultStreamChatGenerics>[] = [];
61-
customAttachments: Attachment<DefaultStreamChatGenerics>[] = [];
62-
imagesToView: Attachment<DefaultStreamChatGenerics>[] = [];
60+
orderedAttachments: Attachment[] = [];
61+
customAttachments: Attachment[] = [];
62+
imagesToView: Attachment[] = [];
6363
imagesToViewCurrentIndex = 0;
6464
customAttachmentsTemplate?: TemplateRef<CustomAttachmentListContext>;
6565
@ViewChild('modalContent', { static: true })
@@ -169,13 +169,13 @@ export class AttachmentListComponent implements OnChanges, OnInit, OnDestroy {
169169
return attachment.type === 'voiceRecording';
170170
}
171171

172-
hasFileSize(attachment: Attachment<DefaultStreamChatGenerics>) {
172+
hasFileSize(attachment: Attachment) {
173173
return (
174174
attachment.file_size && Number.isFinite(Number(attachment.file_size))
175175
);
176176
}
177177

178-
getFileSize(attachment: Attachment<DefaultStreamChatGenerics>) {
178+
getFileSize(attachment: Attachment) {
179179
return prettybytes(Number(attachment.file_size!));
180180
}
181181

@@ -226,9 +226,7 @@ export class AttachmentListComponent implements OnChanges, OnInit, OnDestroy {
226226
return item.image_url || item.img_url || item.thumb_url;
227227
}
228228

229-
getAttachmentContext(
230-
attachment: Attachment<DefaultStreamChatGenerics>
231-
): AttachmentContext {
229+
getAttachmentContext(attachment: Attachment): AttachmentContext {
232230
return { attachment };
233231
}
234232

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ChatClientService } from './chat-client.service';
1010
import { MessageService } from './message.service';
1111

1212
describe('AttachmentService', () => {
13-
let service: AttachmentService<DefaultStreamChatGenerics>;
13+
let service: AttachmentService;
1414
let uploadAttachmentsSpy: jasmine.Spy;
1515
let deleteAttachmentSpy: jasmine.Spy;
1616
let readAsDataURLSpy: jasmine.Spy;

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import { AppSettings, Attachment } from 'stream-chat';
1212
import { ChannelService } from './channel.service';
1313
import { isImageAttachment } from './is-image-attachment';
1414
import { NotificationService } from './notification.service';
15-
import {
16-
AttachmentUpload,
17-
AudioRecording,
18-
DefaultStreamChatGenerics,
19-
} from './types';
15+
import { AttachmentUpload, AudioRecording } from './types';
2016
import { ChatClientService } from './chat-client.service';
2117
import { MessageService } from './message.service';
2218

@@ -28,9 +24,7 @@ import { MessageService } from './message.service';
2824
@Injectable({
2925
providedIn: 'root',
3026
})
31-
export class AttachmentService<
32-
T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
33-
> {
27+
export class AttachmentService {
3428
/**
3529
* Emits the number of uploads in progress.
3630
*
@@ -48,7 +42,7 @@ export class AttachmentService<
4842
*
4943
* By default the SDK components won't display these, but you can provide your own `customAttachmentPreviewListTemplate$` and `customAttachmentListTemplate$` for the [`CustomTemplatesService`](/chat/docs/sdk/angular/services/CustomTemplatesService/).
5044
*/
51-
customAttachments$ = new BehaviorSubject<Attachment<T>[]>([]);
45+
customAttachments$ = new BehaviorSubject<Attachment[]>([]);
5246
/**
5347
* The current number of attachments
5448
*/
@@ -213,7 +207,8 @@ export class AttachmentService<
213207
* Note: If you just want to use your own CDN for file uploads, you don't necessary need this method, you can just specify you own upload function in the [`ChannelService`](/chat/docs/sdk/angular/services/ChannelService/)
214208
* @param attachment
215209
*/
216-
addAttachment(attachment: Attachment<T>) {
210+
addAttachment(attachment: Attachment) {
211+
// @ts-expect-error this is an internal field
217212
attachment.isCustomAttachment = true;
218213
this.createFromAttachments([attachment]);
219214
}
@@ -303,10 +298,10 @@ export class AttachmentService<
303298
* Maps attachments received from the Stream API to uploads. This is useful when editing a message.
304299
* @param attachments Attachemnts received with the message
305300
*/
306-
createFromAttachments(attachments: Attachment<T>[]) {
301+
createFromAttachments(attachments: Attachment[]) {
307302
const attachmentUploads: AttachmentUpload[] = [];
308-
const builtInAttachments: Attachment<T>[] = [];
309-
const customAttachments: Attachment<T>[] = [];
303+
const builtInAttachments: Attachment[] = [];
304+
const customAttachments: Attachment[] = [];
310305
attachments.forEach((attachment) => {
311306
if (this.messageService.isCustomAttachment(attachment)) {
312307
customAttachments.push(attachment);

projects/stream-chat-angular/src/lib/avatar-placeholder/avatar-placeholder.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('AvatarPlaceholderComponent', () => {
4747
expect(avatar.user).toBe(user);
4848

4949
component.type = 'channel';
50-
const channel = { id: 'channel-id' } as Channel<DefaultStreamChatGenerics>;
50+
const channel = { id: 'channel-id' } as Channel;
5151
component.channel = channel;
5252
component.ngOnChanges();
5353
fixture.detectChanges();

projects/stream-chat-angular/src/lib/avatar-placeholder/avatar-placeholder.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export class AvatarPlaceholderComponent implements OnChanges {
3232
/**
3333
* The channel the avatar belongs to (if avatar of a channel is displayed)
3434
*/
35-
@Input() channel?: Channel<DefaultStreamChatGenerics>;
35+
@Input() channel?: Channel;
3636
/**
3737
* The user the avatar belongs to (if avatar of a user is displayed)
3838
*/
39-
@Input() user?: User<DefaultStreamChatGenerics>;
39+
@Input() user?: User;
4040
/**
4141
* The type of the avatar: channel if channel avatar is displayed, user if user avatar is displayed
4242
*/

0 commit comments

Comments
 (0)