stream-chat-angular 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/assets/i18n/en.d.ts +2 -0
  2. package/assets/version.d.ts +1 -1
  3. package/bundles/stream-chat-angular.umd.js +512 -176
  4. package/bundles/stream-chat-angular.umd.js.map +1 -1
  5. package/esm2015/assets/i18n/en.js +3 -1
  6. package/esm2015/assets/version.js +2 -2
  7. package/esm2015/lib/attachment-configuration.service.js +83 -0
  8. package/esm2015/lib/attachment-list/attachment-list.component.js +22 -11
  9. package/esm2015/lib/channel-preview/channel-preview.component.js +4 -4
  10. package/esm2015/lib/channel.service.js +123 -16
  11. package/esm2015/lib/message/message.component.js +11 -2
  12. package/esm2015/lib/message-actions-box/message-actions-box.component.js +5 -3
  13. package/esm2015/lib/message-list/image-load.service.js +2 -1
  14. package/esm2015/lib/message-list/message-list.component.js +158 -75
  15. package/esm2015/lib/types.js +1 -1
  16. package/esm2015/public-api.js +2 -1
  17. package/fesm2015/stream-chat-angular.js +440 -143
  18. package/fesm2015/stream-chat-angular.js.map +1 -1
  19. package/lib/attachment-configuration.service.d.ts +47 -0
  20. package/lib/attachment-list/attachment-list.component.d.ts +6 -4
  21. package/lib/channel.service.d.ts +35 -3
  22. package/lib/message/message.component.d.ts +6 -1
  23. package/lib/message-list/image-load.service.d.ts +1 -0
  24. package/lib/message-list/message-list.component.d.ts +14 -9
  25. package/lib/types.d.ts +6 -0
  26. package/package.json +1 -1
  27. package/public-api.d.ts +1 -0
  28. package/src/assets/i18n/en.ts +2 -0
  29. package/src/assets/styles/css/index.css +1 -1
  30. package/src/assets/styles/css/index.css.map +1 -1
  31. package/src/assets/styles/scss/ImageCarousel.scss +6 -0
  32. package/src/assets/styles/scss/Message.scss +6 -1
  33. package/src/assets/version.ts +1 -1
@@ -0,0 +1,47 @@
1
+ import { Attachment } from 'stream-chat';
2
+ import { AttachmentConfigration, DefaultStreamChatGenerics } from './types';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * The `AttachmentConfigurationService` provides customization for certain attributes of attachments displayed inside the message component.
6
+ */
7
+ export declare class AttachmentConfigurationService<T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> {
8
+ /**
9
+ * 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.
10
+ */
11
+ customImageAttachmentConfigurationHandler?: (a: Attachment<T>, type: 'gallery' | 'single' | 'carousel') => AttachmentConfigration;
12
+ /**
13
+ * 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.
14
+ */
15
+ customVideoAttachmentConfigurationHandler?: (a: Attachment<T>) => AttachmentConfigration;
16
+ /**
17
+ * 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.
18
+ */
19
+ customGiphyAttachmentConfigurationHandler?: (a: Attachment<T>) => AttachmentConfigration;
20
+ /**
21
+ * 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.
22
+ */
23
+ customScrapedImageAttachmentConfigurationHandler?: (a: Attachment<T>) => AttachmentConfigration;
24
+ /**
25
+ * Handles the configuration for image attachments, it's possible to provide your own function to override the default logic
26
+ * @param attachment The attachment to configure
27
+ * @param location Specifies where the image is being displayed
28
+ */
29
+ getImageAttachmentConfiguration(attachment: Attachment<T>, location: 'gallery' | 'single' | 'carousel'): AttachmentConfigration;
30
+ /**
31
+ * Handles the configuration for video attachments, it's possible to provide your own function to override the default logic
32
+ * @param attachment The attachment to configure
33
+ */
34
+ getVideoAttachmentConfiguration(attachment: Attachment<T>): AttachmentConfigration;
35
+ /**
36
+ * Handles the configuration for giphy attachments, it's possible to provide your own function to override the default logic
37
+ * @param attachment The attachment to configure
38
+ */
39
+ getGiphyAttachmentConfiguration(attachment: Attachment<T>): AttachmentConfigration;
40
+ /**
41
+ * Handles the configuration for scraped image attachments, it's possible to provide your own function to override the default logic
42
+ * @param attachment The attachment to configure
43
+ */
44
+ getScrapedImageAttachmentConfiguration(attachment: Attachment<T>): AttachmentConfigration;
45
+ static ɵfac: i0.ɵɵFactoryDeclaration<AttachmentConfigurationService<any>, never>;
46
+ static ɵprov: i0.ɵɵInjectableDeclaration<AttachmentConfigurationService<any>>;
47
+ }
@@ -1,9 +1,9 @@
1
1
  import { OnChanges } from '@angular/core';
2
2
  import { Action, Attachment } from 'stream-chat';
3
- import { ImageLoadService } from '../message-list/image-load.service';
4
3
  import { ModalContext, DefaultStreamChatGenerics } from '../types';
5
4
  import { ChannelService } from '../channel.service';
6
5
  import { CustomTemplatesService } from '../custom-templates.service';
6
+ import { AttachmentConfigurationService } from '../attachment-configuration.service';
7
7
  import { ThemeService } from '../theme.service';
8
8
  import * as i0 from "@angular/core";
9
9
  /**
@@ -11,8 +11,8 @@ import * as i0 from "@angular/core";
11
11
  */
12
12
  export declare class AttachmentListComponent implements OnChanges {
13
13
  readonly customTemplatesService: CustomTemplatesService;
14
- private imageLoadService;
15
14
  private channelService;
15
+ private attachmentConfigurationService;
16
16
  /**
17
17
  * The id of the message the attachments belong to
18
18
  */
@@ -31,7 +31,7 @@ export declare class AttachmentListComponent implements OnChanges {
31
31
  imagesToViewCurrentIndex: number;
32
32
  themeVersion: '1' | '2';
33
33
  private modalContent;
34
- constructor(customTemplatesService: CustomTemplatesService, imageLoadService: ImageLoadService, channelService: ChannelService, themeService: ThemeService);
34
+ constructor(customTemplatesService: CustomTemplatesService, channelService: ChannelService, attachmentConfigurationService: AttachmentConfigurationService, themeService: ThemeService);
35
35
  ngOnChanges(): void;
36
36
  trackById(index: number): number;
37
37
  isImage(attachment: Attachment): boolean;
@@ -40,7 +40,6 @@ export declare class AttachmentListComponent implements OnChanges {
40
40
  isGallery(attachment: Attachment): boolean;
41
41
  isVideo(attachment: Attachment): boolean | "" | undefined;
42
42
  isCard(attachment: Attachment): boolean;
43
- imageLoaded(): void;
44
43
  hasFileSize(attachment: Attachment<DefaultStreamChatGenerics>): boolean | "" | 0 | undefined;
45
44
  getFileSize(attachment: Attachment<DefaultStreamChatGenerics>): string;
46
45
  getModalContext(): ModalContext;
@@ -50,6 +49,9 @@ export declare class AttachmentListComponent implements OnChanges {
50
49
  openImageModal(attachments: Attachment[], selectedIndex?: number): void;
51
50
  stepImages(dir: -1 | 1): void;
52
51
  trackByImageUrl(_: number, item: Attachment): unknown;
52
+ getImageAttachmentConfiguration(attachment: Attachment, type: 'gallery' | 'single' | 'carousel'): import("../types").AttachmentConfigration;
53
+ getVideoAttachmentConfiguration(attachment: Attachment): import("../types").AttachmentConfigration;
54
+ getCardAttachmentConfiguration(attachment: Attachment): import("../types").AttachmentConfigration;
53
55
  get isImageModalPrevButtonVisible(): boolean;
54
56
  get isImageModalNextButtonVisible(): boolean;
55
57
  private createGallery;
@@ -56,6 +56,10 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
56
56
  * Emits the list of currently loaded messages of the active channel.
57
57
  */
58
58
  activeChannelMessages$: Observable<StreamMessage<T>[]>;
59
+ /**
60
+ * Emits the list of pinned messages of the active channel.
61
+ */
62
+ activeChannelPinnedMessages$: Observable<StreamMessage<T>[]>;
59
63
  /**
60
64
  * Emits the id of the currently selected parent message. If no message is selected, it emits undefined.
61
65
  */
@@ -72,6 +76,13 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
72
76
  * Emits the currently selected message to quote
73
77
  */
74
78
  messageToQuote$: Observable<StreamMessage<T> | undefined>;
79
+ /**
80
+ * Emits the ID of the message the message list should jump to (can be a channel message or thread message)
81
+ */
82
+ jumpToMessage$: Observable<{
83
+ id?: string;
84
+ parentId?: string;
85
+ }>;
75
86
  /**
76
87
  * Emits the list of users that are currently typing in the channel (current user is not included)
77
88
  */
@@ -145,10 +156,12 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
145
156
  private channelsSubject;
146
157
  private activeChannelSubject;
147
158
  private activeChannelMessagesSubject;
159
+ private activeChannelPinnedMessagesSubject;
148
160
  private hasMoreChannelsSubject;
149
161
  private activeChannelSubscriptions;
150
162
  private activeParentMessageIdSubject;
151
163
  private activeThreadMessagesSubject;
164
+ private jumpToMessageSubject;
152
165
  private latestMessageDateByUserByChannelsSubject;
153
166
  private filters;
154
167
  private sort;
@@ -186,16 +199,19 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
186
199
  /**
187
200
  * Sets the given `message` as an active parent message. If `undefined` is provided, it will deleselect the current parent message.
188
201
  * @param message
202
+ * @param loadMessagesForm
189
203
  */
190
- setAsActiveParentMessage(message: StreamMessage<T> | undefined): Promise<void>;
204
+ setAsActiveParentMessage(message: StreamMessage<T> | undefined, loadMessagesForm?: 'request' | 'state'): Promise<void>;
191
205
  /**
192
206
  * Loads the next page of messages of the active channel. The page size can be set in the [query option](https://getstream.io/chat/docs/javascript/query_channels/?language=javascript#query-options) object.
207
+ * @param direction
193
208
  */
194
- loadMoreMessages(): Promise<void>;
209
+ loadMoreMessages(direction?: 'older' | 'newer'): Promise<void>;
195
210
  /**
196
211
  * Loads the next page of messages of the active thread. The page size can be set in the [query option](https://getstream.io/chat/docs/javascript/query_channels/?language=javascript#query-options) object.
212
+ * @param direction
197
213
  */
198
- loadMoreThreadReplies(): Promise<void>;
214
+ loadMoreThreadReplies(direction?: 'older' | 'newer'): Promise<void>;
199
215
  /**
200
216
  * Queries the channels with the given filters, sorts and options. More info about [channel querying](https://getstream.io/chat/docs/javascript/query_channels/?language=javascript) can be found in the platform documentation. By default the first channel in the list will be set as active channel and will be marked as read.
201
217
  * @param filters
@@ -281,6 +297,22 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
281
297
  */
282
298
  selectMessageToQuote(message: StreamMessage | undefined): void;
283
299
  private sendMessageRequest;
300
+ /**
301
+ * Jumps to the selected message inside the message list, if the message is not yet loaded, it'll load the message (and it's surroundings) from the API.
302
+ * @param messageId The ID of the message to be loaded, 'latest' means jump to the latest messages
303
+ * @param parentMessageId The ID of the parent message if we want to load a thread message
304
+ */
305
+ jumpToMessage(messageId: string, parentMessageId?: string): Promise<void>;
306
+ /**
307
+ * Pins the given message in the channel
308
+ * @param message
309
+ */
310
+ pinMessage(message: StreamMessage<DefaultStreamChatGenerics>): Promise<void>;
311
+ /**
312
+ * Removes the given message from pinned messages
313
+ * @param message
314
+ */
315
+ unpinMessage(message: StreamMessage<DefaultStreamChatGenerics>): Promise<void>;
284
316
  private handleNotification;
285
317
  private handleRemovedFromChannelNotification;
286
318
  private handleNewMessageNotification;
@@ -36,6 +36,10 @@ export declare class MessageComponent implements OnInit, OnChanges, OnDestroy {
36
36
  * Determines if the message is being dispalyed in a channel or in a [thread](https://getstream.io/chat/docs/javascript/threads/?language=javascript).
37
37
  */
38
38
  mode: 'thread' | 'main';
39
+ /**
40
+ * Highlighting is used to add visual emphasize to a message when jumping to the message
41
+ */
42
+ isHighlighted: boolean;
39
43
  readonly themeVersion: '1' | '2';
40
44
  canReceiveReadEvents: boolean | undefined;
41
45
  canReactToMessage: boolean | undefined;
@@ -100,8 +104,9 @@ export declare class MessageComponent implements OnInit, OnChanges, OnDestroy {
100
104
  setAsActiveParentMessage(): void;
101
105
  getMentionContext(messagePart: MessagePart): MentionTemplateContext;
102
106
  getMessageActionsBoxContext(): MessageActionsBoxContext;
107
+ jumpToMessage(messageId: string, parentMessageId?: string): void;
103
108
  private createMessageParts;
104
109
  static ɵfac: i0.ɵɵFactoryDeclaration<MessageComponent, never>;
105
- static ɵcmp: i0.ɵɵComponentDeclaration<MessageComponent, "stream-message", never, { "message": "message"; "enabledMessageActions": "enabledMessageActions"; "isLastSentMessage": "isLastSentMessage"; "mode": "mode"; }, {}, never, never>;
110
+ static ɵcmp: i0.ɵɵComponentDeclaration<MessageComponent, "stream-message", never, { "message": "message"; "enabledMessageActions": "enabledMessageActions"; "isLastSentMessage": "isLastSentMessage"; "mode": "mode"; "isHighlighted": "isHighlighted"; }, {}, never, never>;
106
111
  }
107
112
  export {};
@@ -2,6 +2,7 @@ import { Subject } from 'rxjs';
2
2
  import * as i0 from "@angular/core";
3
3
  /**
4
4
  * The `ImageLoadService` is used to position the scrollbar in the message list
5
+ * @deprecated - This class is no longer used by SDK components as image sizes are fixed
5
6
  */
6
7
  export declare class ImageLoadService {
7
8
  /**
@@ -1,20 +1,18 @@
1
- import { AfterViewChecked, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
1
+ import { AfterViewChecked, AfterViewInit, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
2
2
  import { ChannelService } from '../channel.service';
3
3
  import { Observable } from 'rxjs';
4
4
  import { MessageContext, StreamMessage, TypingIndicatorContext } from '../types';
5
5
  import { ChatClientService } from '../chat-client.service';
6
6
  import { GroupStyle } from './group-styles';
7
- import { ImageLoadService } from './image-load.service';
8
7
  import { UserResponse } from 'stream-chat';
9
8
  import { CustomTemplatesService } from '../custom-templates.service';
10
9
  import * as i0 from "@angular/core";
11
10
  /**
12
11
  * The `MessageList` component renders a scrollable list of messages.
13
12
  */
14
- export declare class MessageListComponent implements AfterViewChecked, OnChanges, OnInit, OnDestroy {
13
+ export declare class MessageListComponent implements AfterViewChecked, OnChanges, OnInit, OnDestroy, AfterViewInit {
15
14
  private channelService;
16
15
  private chatClientService;
17
- private imageLoadService;
18
16
  private customTemplatesService;
19
17
  /**
20
18
  * Determines if the message list should display channel messages or [thread messages](https://getstream.io/chat/docs/javascript/threads/?language=javascript).
@@ -34,27 +32,30 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
34
32
  groupStyles: GroupStyle[];
35
33
  lastSentMessageId: string | undefined;
36
34
  parentMessage: StreamMessage | undefined;
35
+ highlightedMessageId: string | undefined;
37
36
  private scrollContainer;
38
37
  private parentMessageElement;
39
- private latestMessageDate;
38
+ private latestMessage;
40
39
  private hasNewMessages;
41
40
  private containerHeight;
42
- private oldestMessageDate;
41
+ private oldestMessage;
43
42
  private olderMassagesLoaded;
44
43
  private isNewMessageSentByUser;
45
- private readonly isUserScrolledUpThreshold;
46
44
  private subscriptions;
45
+ private newMessageSubscription;
47
46
  private prevScrollTop;
48
47
  private usersTypingInChannel$;
49
48
  private usersTypingInThread$;
50
- constructor(channelService: ChannelService, chatClientService: ChatClientService, imageLoadService: ImageLoadService, customTemplatesService: CustomTemplatesService);
49
+ private isLatestMessageInList;
50
+ constructor(channelService: ChannelService, chatClientService: ChatClientService, customTemplatesService: CustomTemplatesService);
51
51
  ngOnInit(): void;
52
52
  ngOnChanges(changes: SimpleChanges): void;
53
+ ngAfterViewInit(): void;
53
54
  ngAfterViewChecked(): void;
54
55
  ngOnDestroy(): void;
55
56
  trackByMessageId(index: number, item: StreamMessage): string;
56
57
  trackByUserId(index: number, user: UserResponse): string;
57
- scrollToLatestMessage(): void;
58
+ jumpToLatestMessage(): void;
58
59
  scrollToBottom(): void;
59
60
  scrollToTop(): void;
60
61
  scrolled(): void;
@@ -65,10 +66,14 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
65
66
  replyCount: number | undefined;
66
67
  };
67
68
  private preserveScrollbarPosition;
69
+ private getScrollPosition;
68
70
  private shouldLoadMoreMessages;
69
71
  private setMessages$;
70
72
  private resetScrollState;
71
73
  private get usersTyping$();
74
+ private scrollMessageIntoView;
75
+ private scrollToLatestMessage;
76
+ private newMessageReceived;
72
77
  static ɵfac: i0.ɵɵFactoryDeclaration<MessageListComponent, never>;
73
78
  static ɵcmp: i0.ɵɵComponentDeclaration<MessageListComponent, "stream-message-list", never, { "mode": "mode"; "direction": "direction"; }, {}, never, never>;
74
79
  }
package/lib/types.d.ts CHANGED
@@ -103,6 +103,7 @@ export declare type MessageContext = {
103
103
  enabledMessageActions: string[];
104
104
  isLastSentMessage: boolean | undefined;
105
105
  mode: 'thread' | 'main';
106
+ isHighlighted: boolean;
106
107
  };
107
108
  export declare type ChannelActionsContext<T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
108
109
  channel: Channel<T>;
@@ -179,3 +180,8 @@ export declare type ThreadHeaderContext = {
179
180
  closeThreadHandler: Function;
180
181
  };
181
182
  export declare type MessageReactionType = 'angry' | 'haha' | 'like' | 'love' | 'sad' | 'wow';
183
+ export declare type AttachmentConfigration = {
184
+ url: string;
185
+ height: string;
186
+ width: string;
187
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat-angular",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Angular components to create chat conversations or livestream style chat",
5
5
  "author": "GetStream",
6
6
  "homepage": "https://getstream.io/chat/",
package/public-api.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './lib/chat-client.service';
2
2
  export * from './lib/channel.service';
3
3
  export * from './lib/theme.service';
4
4
  export * from './lib/attachment.service';
5
+ export * from './lib/attachment-configuration.service';
5
6
  export * from './lib/stream-i18n.service';
6
7
  export * from './lib/avatar/avatar.component';
7
8
  export * from './lib/avatar-placeholder/avatar-placeholder.component';
@@ -37,6 +37,7 @@ export const en = {
37
37
  'Message has been successfully flagged':
38
38
  'Message has been successfully flagged',
39
39
  'Message pinned': 'Message pinned',
40
+ 'Message unpinned': 'Message unpinned',
40
41
  Mute: 'Mute',
41
42
  New: 'New',
42
43
  'New Messages!': 'New Messages!',
@@ -95,6 +96,7 @@ export const en = {
95
96
  "You can't send thread replies in this channel":
96
97
  "You can't send thread replies in this channel",
97
98
  'Unsupported file type: {{type}}': 'Unsupported file type: {{type}}',
99
+ 'Message not found': 'Message not found',
98
100
  'No chats here yet…': 'No chats here yet…',
99
101
  'user is typing': '{{ user }} is typing',
100
102
  'users are typing': '{{ users }} are typing',