Skip to content

Commit efaa982

Browse files
committed
refactor: Minor improvements to chat component
1 parent 6a1a52c commit efaa982

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

projects/igniteui-angular/chat/src/chat.component.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ChatContextType<T extends ChatContextUnion> =
4040
: T extends ChatMessageRenderContext
4141
? IgcChatMessage
4242
: T extends ChatInputRenderContext
43-
? { value: string; attachments: IgcChatMessageAttachment[] }
43+
? string
4444
: T extends ChatRenderContext
4545
? { instance: IgcChatComponent }
4646
: never;
@@ -214,14 +214,13 @@ export class IgxChatComponent implements OnInit, OnDestroy {
214214
}
215215
}
216216

217-
if (newTemplateKeys.length > 0) {
218-
this._oldTemplates = {};
219-
for (const key of newTemplateKeys) {
220-
const ref = newTemplates[key];
221-
if (ref) {
222-
this._oldTemplates[key] = ref as any;
223-
templateCopies[key] = this._createTemplateRenderer(ref);
224-
}
217+
this._oldTemplates = {};
218+
219+
for (const key of newTemplateKeys) {
220+
const ref = newTemplates[key];
221+
if (ref) {
222+
(this._oldTemplates as Record<string, TemplateRef<unknown>>)[key] = ref;
223+
templateCopies[key] = this._createTemplateRenderer(ref);
225224
}
226225
}
227226

@@ -283,7 +282,7 @@ export interface ChatInputContext {
283282
* </ng-template>
284283
* ```
285284
*/
286-
@Directive({ selector: '[igxChatMessageContext]' })
285+
@Directive({ selector: '[igxChatMessageContext]', standalone: true })
287286
export class IgxChatMessageContextDirective {
288287

289288
public static ngTemplateContextGuard(_: IgxChatMessageContextDirective, ctx: unknown): ctx is { $implicit: IgcChatMessage } {
@@ -302,7 +301,7 @@ export class IgxChatMessageContextDirective {
302301
* </ng-template>
303302
* ```
304303
*/
305-
@Directive({ selector: '[igxChatAttachmentContext]' })
304+
@Directive({ selector: '[igxChatAttachmentContext]', standalone: true })
306305
export class IgxChatAttachmentContextDirective {
307306

308307
public static ngTemplateContextGuard(_: IgxChatAttachmentContextDirective, ctx: unknown): ctx is { $implicit: IgcChatMessageAttachment } {
@@ -321,7 +320,7 @@ export class IgxChatAttachmentContextDirective {
321320
* </ng-template>
322321
* ```
323322
*/
324-
@Directive({ selector: '[igxChatInputContext]' })
323+
@Directive({ selector: '[igxChatInputContext]', standalone: true })
325324
export class IgxChatInputContextDirective {
326325

327326
public static ngTemplateContextGuard(_: IgxChatInputContextDirective, ctx: unknown): ctx is ChatInputContext {

0 commit comments

Comments
 (0)