Skip to content

Commit ad882f4

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
Chat: Rename onAttachmentDownload to onAttachmentDownloadClick, expand Attachment type (#31584)
Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent 6501ab9 commit ad882f4

File tree

15 files changed

+76
-70
lines changed

15 files changed

+76
-70
lines changed

packages/devextreme-angular/src/ui/chat/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424

2525
import DataSource from 'devextreme/data/data_source';
2626
import dxChat from 'devextreme/ui/chat';
27-
import { Alert, Message, AttachmentDownloadEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, OptionChangedEvent, TypingEndEvent, TypingStartEvent, User } from 'devextreme/ui/chat';
27+
import { Alert, Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, OptionChangedEvent, TypingEndEvent, TypingStartEvent, User } from 'devextreme/ui/chat';
2828
import { DataSourceOptions } from 'devextreme/data/data_source';
2929
import { Store } from 'devextreme/data/store';
3030
import { Format } from 'devextreme/common/core/localization';
@@ -465,7 +465,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
465465
466466
467467
*/
468-
@Output() onAttachmentDownload: EventEmitter<AttachmentDownloadEvent>;
468+
@Output() onAttachmentDownloadClick: EventEmitter<AttachmentDownloadClickEvent>;
469469

470470
/**
471471
@@ -765,7 +765,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
765765
super(elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId);
766766

767767
this._createEventEmitters([
768-
{ subscribe: 'attachmentDownload', emit: 'onAttachmentDownload' },
768+
{ subscribe: 'attachmentDownloadClick', emit: 'onAttachmentDownloadClick' },
769769
{ subscribe: 'disposing', emit: 'onDisposing' },
770770
{ subscribe: 'initialized', emit: 'onInitialized' },
771771
{ subscribe: 'messageDeleted', emit: 'onMessageDeleted' },

packages/devextreme-metadata/make-angular-metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Ng.makeMetadata({
5050
removeMembers(/\/calendar:dxCalendarOptions.todayButtonText/),
5151
removeMembers(/\/card_view:/),
5252
removeMembers(/\/chat:TextMessage.attachments/),
53-
removeMembers(/\/chat:dxChatOptions\.(fileUploaderOptions|onAttachmentDownload)/),
53+
removeMembers(/\/chat:dxChatOptions\.(fileUploaderOptions|onAttachmentDownloadClick)/),
5454
removeMembers(/\/form:dxFormOptions\.(aiIntegration|onSmartPasting|onSmartPasted|smartPaste)/),
5555
removeMembers(/\/form:dxFormSimpleItem\.aiOptions/),
5656
removeMembers(/\/form:FormPredefinedButtonItem/),

packages/devextreme-react/src/chat.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dxChat, {
88
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
99
import NestedOption from "./core/nested-option";
1010

11-
import type { Message, AttachmentDownloadEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, TypingEndEvent, TypingStartEvent, Attachment as ChatAttachment, User as ChatUser } from "devextreme/ui/chat";
11+
import type { Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, TypingEndEvent, TypingStartEvent, Attachment as ChatAttachment, User as ChatUser } from "devextreme/ui/chat";
1212
import type { DisposingEvent as FileUploaderDisposingEvent, InitializedEvent as FileUploaderInitializedEvent, BeforeSendEvent, ContentReadyEvent, DropZoneEnterEvent, DropZoneLeaveEvent, FilesUploadedEvent, OptionChangedEvent, ProgressEvent, UploadAbortedEvent, UploadedEvent, UploadErrorEvent, UploadStartedEvent, ValueChangedEvent, UploadHttpMethod, FileUploadMode } from "devextreme/ui/file_uploader";
1313
import type { Format, ValidationStatus } from "devextreme/common";
1414

@@ -19,7 +19,7 @@ type ReplaceFieldTypes<TSource, TReplacement> = {
1919
}
2020

2121
type IChatOptionsNarrowedEvents = {
22-
onAttachmentDownload?: ((e: AttachmentDownloadEvent) => void) | undefined;
22+
onAttachmentDownloadClick?: ((e: AttachmentDownloadClickEvent) => void) | undefined;
2323
onDisposing?: ((e: DisposingEvent) => void);
2424
onInitialized?: ((e: InitializedEvent) => void);
2525
onMessageDeleted?: ((e: MessageDeletedEvent) => void) | undefined;
@@ -60,7 +60,7 @@ const Chat = memo(
6060
), []);
6161

6262
const subscribableOptions = useMemo(() => (["items"]), []);
63-
const independentEvents = useMemo(() => (["onAttachmentDownload","onDisposing","onInitialized","onMessageDeleted","onMessageDeleting","onMessageEditCanceled","onMessageEditingStart","onMessageEntered","onMessageUpdated","onMessageUpdating","onTypingEnd","onTypingStart"]), []);
63+
const independentEvents = useMemo(() => (["onAttachmentDownloadClick","onDisposing","onInitialized","onMessageDeleted","onMessageDeleting","onMessageEditCanceled","onMessageEditingStart","onMessageEntered","onMessageUpdated","onMessageUpdating","onTypingEnd","onTypingStart"]), []);
6464

6565
const defaults = useMemo(() => ({
6666
defaultItems: "items",

packages/devextreme-vue/src/chat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import UploadInfo from "devextreme/file_management/upload_info";
88
import {
99
Alert,
1010
Message,
11-
AttachmentDownloadEvent,
11+
AttachmentDownloadClickEvent,
1212
DisposingEvent,
1313
InitializedEvent,
1414
MessageDeletedEvent,
@@ -76,7 +76,7 @@ type AccessibleOptions = Pick<Properties,
7676
"items" |
7777
"messageTemplate" |
7878
"messageTimestampFormat" |
79-
"onAttachmentDownload" |
79+
"onAttachmentDownloadClick" |
8080
"onDisposing" |
8181
"onInitialized" |
8282
"onMessageDeleted" |
@@ -124,7 +124,7 @@ const componentConfig = {
124124
items: Array as PropType<Array<Message>>,
125125
messageTemplate: {},
126126
messageTimestampFormat: [Object, String, Function] as PropType<Format | CommonFormat | (((value: number | Date) => string)) | Record<string, any> | string>,
127-
onAttachmentDownload: Function as PropType<((e: AttachmentDownloadEvent) => void)>,
127+
onAttachmentDownloadClick: Function as PropType<((e: AttachmentDownloadClickEvent) => void)>,
128128
onDisposing: Function as PropType<((e: DisposingEvent) => void)>,
129129
onInitialized: Function as PropType<((e: InitializedEvent) => void)>,
130130
onMessageDeleted: Function as PropType<((e: MessageDeletedEvent) => void)>,
@@ -168,7 +168,7 @@ const componentConfig = {
168168
"update:items": null,
169169
"update:messageTemplate": null,
170170
"update:messageTimestampFormat": null,
171-
"update:onAttachmentDownload": null,
171+
"update:onAttachmentDownloadClick": null,
172172
"update:onDisposing": null,
173173
"update:onInitialized": null,
174174
"update:onMessageDeleted": null,

packages/devextreme/js/__internal/ui/chat/chat.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isDefined } from '@js/core/utils/type';
88
import DataHelperMixin from '@js/data_helper';
99
import type dxChat from '@js/ui/chat';
1010
import type {
11-
AttachmentDownloadEvent,
11+
AttachmentDownloadClickEvent,
1212
Message,
1313
MessageDeletedEvent,
1414
MessageDeletingEvent,
@@ -74,7 +74,7 @@ class Chat extends Widget<Properties> {
7474

7575
_messageUpdatedAction?: (e: Partial<MessageUpdatedEvent>) => void;
7676

77-
_attachmentDownloadAction?: (e: Partial<AttachmentDownloadEvent>) => void;
77+
_attachmentDownloadAction?: (e: Partial<AttachmentDownloadClickEvent>) => void;
7878

7979
_getDefaultOptions(): Properties {
8080
return {
@@ -108,7 +108,7 @@ class Chat extends Widget<Properties> {
108108
onMessageEntered: undefined,
109109
onTypingEnd: undefined,
110110
onTypingStart: undefined,
111-
onAttachmentDownload: undefined,
111+
onAttachmentDownloadClick: undefined,
112112
};
113113
}
114114

@@ -201,7 +201,7 @@ class Chat extends Widget<Properties> {
201201
// @ts-expect-error
202202
const isLoading = this._dataController.isLoading();
203203
const currentUserId = user?.id;
204-
const onAttachmentDownload = this._getAttachmentDownloadHandler();
204+
const onAttachmentDownloadClick = this._getAttachmentDownloadHandler();
205205

206206
const options: MessageListProperties = {
207207
items,
@@ -230,21 +230,21 @@ class Chat extends Widget<Properties> {
230230
onEscapeKeyPressed: () => {
231231
this.focus();
232232
},
233-
onAttachmentDownload,
233+
onAttachmentDownloadClick,
234234
};
235235

236236
return options;
237237
}
238238

239-
_getAttachmentDownloadHandler(): ((e: AttachmentDownloadEvent) => void) | undefined {
240-
const { onAttachmentDownload } = this.option();
239+
_getAttachmentDownloadHandler(): ((e: AttachmentDownloadClickEvent) => void) | undefined {
240+
const { onAttachmentDownloadClick } = this.option();
241241

242-
if (!onAttachmentDownload) {
242+
if (!onAttachmentDownloadClick) {
243243
return;
244244
}
245245

246246
// eslint-disable-next-line consistent-return
247-
return (e: AttachmentDownloadEvent): void => { this._attachmentDownloadAction?.(e); };
247+
return (e: AttachmentDownloadClickEvent): void => { this._attachmentDownloadAction?.(e); };
248248
}
249249

250250
protected _allowEditAction(message: Message): boolean {
@@ -541,7 +541,7 @@ class Chat extends Widget<Properties> {
541541

542542
_createAttachmentDownloadAction(): void {
543543
this._attachmentDownloadAction = this._createActionByOption(
544-
'onAttachmentDownload',
544+
'onAttachmentDownloadClick',
545545
{ excludeValidators: ['disabled'] },
546546
);
547547
}
@@ -653,9 +653,11 @@ class Chat extends Widget<Properties> {
653653
case 'onTypingEnd':
654654
this._createTypingEndAction();
655655
break;
656-
case 'onAttachmentDownload':
656+
case 'onAttachmentDownloadClick':
657657
this._createAttachmentDownloadAction();
658-
this._messageList.option({ onAttachmentDownload: this._getAttachmentDownloadHandler() });
658+
this._messageList.option({
659+
onAttachmentDownloadClick: this._getAttachmentDownloadHandler(),
660+
});
659661
break;
660662
case 'showDayHeaders':
661663
case 'showAvatar':

packages/devextreme/js/__internal/ui/chat/file_view/file.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ClickEvent } from '@js/ui/button';
55
import Button from '@js/ui/button';
66
import type {
77
Attachment,
8-
AttachmentDownloadEvent,
8+
AttachmentDownloadClickEvent,
99
} from '@js/ui/chat';
1010
import { getImageContainer } from '@ts/core/utils/m_icon';
1111
import type { DOMComponentProperties } from '@ts/core/widget/dom_component';
@@ -23,7 +23,7 @@ export type Properties = DOMComponentProperties<File> & {
2323

2424
data: Attachment;
2525

26-
onDownload?: (e: AttachmentDownloadEvent) => void;
26+
onDownload?: (e: AttachmentDownloadClickEvent) => void;
2727
};
2828

2929
export const CHAT_FILE_CLASS = 'dx-chat-file';
@@ -35,7 +35,7 @@ const CHAT_FILE_DOWNLOAD_BUTTON_CLASS = 'dx-chat-file-download-button';
3535
class File extends DOMComponent<File, Properties> {
3636
private _downloadButton?: Button | null;
3737

38-
private _downloadAction?: (e: Partial<AttachmentDownloadEvent>) => void;
38+
private _downloadAction?: (e: Partial<AttachmentDownloadClickEvent>) => void;
3939

4040
_getDefaultOptions(): Properties {
4141
return {

packages/devextreme/js/__internal/ui/chat/file_view/file_view.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import messageLocalization from '@js/common/core/localization/message';
22
import $ from '@js/core/renderer';
3-
import type { Attachment, AttachmentDownloadEvent } from '@js/ui/chat';
3+
import type { Attachment, AttachmentDownloadClickEvent } from '@js/ui/chat';
44
import type { DOMComponentProperties } from '@ts/core/widget/dom_component';
55
import DOMComponent from '@ts/core/widget/dom_component';
66
import type { OptionChanged } from '@ts/core/widget/types';
@@ -16,7 +16,7 @@ export interface FileViewProperties extends DOMComponentProperties<FileView> {
1616

1717
files?: Attachment[];
1818

19-
onDownload?: (e: AttachmentDownloadEvent) => void;
19+
onDownload?: (e: AttachmentDownloadClickEvent) => void;
2020
}
2121

2222
export const CHAT_FILE_VIEW_CLASS = 'dx-chat-file-view';

packages/devextreme/js/__internal/ui/chat/messagebubble.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import messageLocalization from '@js/common/core/localization/message';
22
import { getPublicElement } from '@js/core/element';
33
import type { dxElementWrapper } from '@js/core/renderer';
44
import $ from '@js/core/renderer';
5-
import type { Attachment, AttachmentDownloadEvent, Message } from '@js/ui/chat';
5+
import type { Attachment, AttachmentDownloadClickEvent, Message } from '@js/ui/chat';
66
import type { WidgetOptions } from '@js/ui/widget/ui.widget';
77
import { ICON_CLASS } from '@ts/core/utils/m_icon';
88
import type { OptionChanged } from '@ts/core/widget/types';
@@ -26,7 +26,7 @@ export interface Properties extends WidgetOptions<MessageBubble> {
2626
src?: string;
2727
alt?: string;
2828
attachments?: Attachment[];
29-
onAttachmentDownload?: (e: AttachmentDownloadEvent) => void;
29+
onAttachmentDownloadClick?: (e: AttachmentDownloadClickEvent) => void;
3030
template?: ((message: Message, container: Element) => void) | null;
3131
}
3232

@@ -138,7 +138,7 @@ class MessageBubble extends Widget<Properties> {
138138
activeStateEnabled,
139139
focusStateEnabled,
140140
hoverStateEnabled,
141-
onAttachmentDownload,
141+
onAttachmentDownloadClick,
142142
} = this.option();
143143

144144
if (!this._$attachments) {
@@ -153,7 +153,7 @@ class MessageBubble extends Widget<Properties> {
153153
focusStateEnabled,
154154
hoverStateEnabled,
155155
files: attachments,
156-
onDownload: onAttachmentDownload,
156+
onDownload: onAttachmentDownloadClick,
157157
});
158158
}
159159
}
@@ -189,7 +189,7 @@ class MessageBubble extends Widget<Properties> {
189189
case 'isEdited':
190190
this._updateMessageData(name, value);
191191
break;
192-
case 'onAttachmentDownload':
192+
case 'onAttachmentDownloadClick':
193193
case 'attachments':
194194
this._renderAttachmentsElement();
195195
this._renderAttachments();

packages/devextreme/js/__internal/ui/chat/messagegroup.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import $ from '@js/core/renderer';
66
import dateSerialization from '@js/core/utils/date_serialization';
77
import { isDate, isDefined } from '@js/core/utils/type';
88
import type {
9-
AttachmentDownloadEvent, ImageMessage, Message, TextMessage,
9+
AttachmentDownloadClickEvent, ImageMessage, Message, TextMessage,
1010
} from '@js/ui/chat';
1111
import type { WidgetOptions } from '@js/ui/widget/ui.widget';
1212
import type { OptionChanged } from '@ts/core/widget/types';
@@ -42,7 +42,7 @@ export interface Properties extends WidgetOptions<MessageGroup> {
4242
showMessageTimestamp: boolean;
4343
messageTimestampFormat?: Format;
4444
messageTemplate?: MessageTemplate;
45-
onAttachmentDownload?: (e: AttachmentDownloadEvent) => void;
45+
onAttachmentDownloadClick?: (e: AttachmentDownloadClickEvent) => void;
4646
}
4747

4848
class MessageGroup extends Widget<Properties> {
@@ -123,15 +123,15 @@ class MessageGroup extends Widget<Properties> {
123123
}
124124

125125
_getMessageBubbleOptions(message: Message): MessageBubbleProperties {
126-
const { messageTemplate, onAttachmentDownload } = this.option();
126+
const { messageTemplate, onAttachmentDownloadClick } = this.option();
127127

128128
const { isDeleted, type, attachments } = message;
129129

130130
const options: MessageBubbleProperties = {
131131
isDeleted,
132132
type,
133133
attachments,
134-
onAttachmentDownload,
134+
onAttachmentDownloadClick,
135135
};
136136

137137
if (type === 'image') {
@@ -313,7 +313,7 @@ class MessageGroup extends Widget<Properties> {
313313
case 'showMessageTimestamp':
314314
case 'messageTemplate':
315315
case 'messageTimestampFormat':
316-
case 'onAttachmentDownload':
316+
case 'onAttachmentDownloadClick':
317317
this._invalidate();
318318
break;
319319
default:

packages/devextreme/js/__internal/ui/chat/messagelist.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getHeight } from '@js/core/utils/size';
1414
import { isDate, isDefined } from '@js/core/utils/type';
1515
import type { DxEvent } from '@js/events';
1616
import type {
17-
AttachmentDownloadEvent, Message, TextMessage, User,
17+
AttachmentDownloadClickEvent, Message, TextMessage, User,
1818
} from '@js/ui/chat';
1919
import type { Item as ContextMenuItem } from '@js/ui/context_menu';
2020
import type dxContextMenu from '@js/ui/context_menu';
@@ -104,7 +104,7 @@ export interface Properties extends WidgetOptions<MessageList> {
104104
showAvatar: boolean;
105105
showUserName: boolean;
106106
showMessageTimestamp: boolean;
107-
onAttachmentDownload?: (e: AttachmentDownloadEvent) => void;
107+
onAttachmentDownloadClick?: (e: AttachmentDownloadClickEvent) => void;
108108
onMessageEditingStart?: (e: MessageEditingEvent) => () => void;
109109
onMessageDeleting?: (e: MessageDeletingEvent) => void;
110110
onEscapeKeyPressed?: (e: KeyboardEvent) => void;
@@ -278,7 +278,7 @@ class MessageList extends Widget<Properties> {
278278
showMessageTimestamp,
279279
messageTimestampFormat,
280280
messageTemplate,
281-
onAttachmentDownload,
281+
onAttachmentDownloadClick,
282282
} = this.option();
283283

284284
const $messageGroup = $('<div>').appendTo(this._$content);
@@ -291,7 +291,7 @@ class MessageList extends Widget<Properties> {
291291
showMessageTimestamp,
292292
messageTimestampFormat,
293293
messageTemplate,
294-
onAttachmentDownload,
294+
onAttachmentDownloadClick,
295295
});
296296
}
297297

@@ -837,7 +837,7 @@ class MessageList extends Widget<Properties> {
837837
case 'emptyViewTemplate':
838838
case 'dayHeaderFormat':
839839
case 'messageTimestampFormat':
840-
case 'onAttachmentDownload':
840+
case 'onAttachmentDownloadClick':
841841
this._invalidate();
842842
break;
843843
case 'items':

0 commit comments

Comments
 (0)