Skip to content

Commit

Permalink
Merge pull request #478 from GetStream/custom-template-change-detecti…
Browse files Browse the repository at this point in the history
…on-bug

fix: some custom templates not properly updated
  • Loading branch information
szuperaz authored Sep 24, 2023
2 parents 3bca47d + fb1c292 commit 40b6ea5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</ng-template>
<ng-container
*ngTemplateOutlet="
(messageActionsBoxTemplate$ | async) ||
(customTemplatesService.messageActionsBoxTemplate$ | async) ||
defaultMessageActionsBox;
context: getMessageActionsBoxContext()
"
Expand Down Expand Up @@ -159,7 +159,8 @@
</ng-template>
<ng-container
*ngTemplateOutlet="
(messageReactionsTemplate$ | async) || defaultMessageReactions;
(customTemplatesService.messageReactionsTemplate$ | async) ||
defaultMessageReactions;
context: getMessageReactionsContext()
"
></ng-container>
Expand Down Expand Up @@ -250,7 +251,8 @@
</ng-template>
<ng-container
*ngTemplateOutlet="
(mentionTemplate$ | async) || defaultMention;
(customTemplatesService.mentionTemplate$ | async) ||
defaultMention;
context: getMentionContext(part)
"
></ng-container>
Expand Down Expand Up @@ -307,7 +309,8 @@
<ng-template #systemMessage>
<ng-container
*ngTemplateOutlet="
(systemMessageTemplate$ | async) || defaultSystemMessage;
(customTemplatesService.systemMessageTemplate$ | async) ||
defaultSystemMessage;
context: getMessageContext()
"
></ng-container>
Expand Down Expand Up @@ -379,7 +382,8 @@
</ng-template>
<ng-container
*ngTemplateOutlet="
(attachmentListTemplate$ | async) || defaultAttachments;
(customTemplatesService.attachmentListTemplate$ | async) ||
defaultAttachments;
context: getQuotedMessageAttachmentListContext()
"
></ng-container>
Expand Down Expand Up @@ -476,7 +480,8 @@
<ng-template #deliveredStatus>
<ng-container
*ngTemplateOutlet="
(deliveredStatusTemplate$ | async) || defaultDeliveredStatus;
(customTemplatesService.deliveredStatusTemplate$ | async) ||
defaultDeliveredStatus;
context: getDeliveredStatusContext()
"
></ng-container>
Expand Down Expand Up @@ -512,7 +517,8 @@
<ng-template #sendingStatus>
<ng-container
*ngTemplateOutlet="
(sendingStatusTemplate$ | async) || defaultSendingStatus;
(customTemplatesService.sendingStatusTemplate$ | async) ||
defaultSendingStatus;
context: getSendingStatusContext()
"
></ng-container>
Expand Down Expand Up @@ -546,7 +552,8 @@
<ng-template #readStatus>
<ng-container
*ngTemplateOutlet="
(readStatusTemplate$ | async) || defaultReadStatus;
(customTemplatesService.readStatusTemplate$ | async) ||
defaultReadStatus;
context: getReadStatusContext()
"
></ng-container>
Expand Down Expand Up @@ -642,7 +649,8 @@
</ng-template>
<ng-container
*ngTemplateOutlet="
(attachmentListTemplate$ | async) || defaultAttachments;
(customTemplatesService.attachmentListTemplate$ | async) ||
defaultAttachments;
context: getAttachmentListContext()
"
></ng-container>
Expand Down
41 changes: 2 additions & 39 deletions projects/stream-chat-angular/src/lib/message/message.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Component,
ElementRef,
Input,
TemplateRef,
OnChanges,
SimpleChanges,
ViewChild,
Expand All @@ -28,7 +27,7 @@ import {
SystemMessageContext,
} from '../types';
import emojiRegex from 'emoji-regex';
import { Observable, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';
import { CustomTemplatesService } from '../custom-templates.service';
import { listUsers } from '../list-users';
import { ThemeService } from '../theme.service';
Expand Down Expand Up @@ -83,28 +82,6 @@ export class MessageComponent implements OnInit, OnChanges, OnDestroy {
isReactionSelectorOpen = false;
visibleMessageActionsCount = 0;
messageTextParts: MessagePart[] = [];
mentionTemplate$?: Observable<
TemplateRef<MentionTemplateContext> | undefined
>;
deliveredStatusTemplate$?: Observable<
TemplateRef<DeliveredStatusContext> | undefined
>;
sendingStatusTemplate$?: Observable<
TemplateRef<SendingStatusContext> | undefined
>;
readStatusTemplate$?: Observable<TemplateRef<ReadStatusContext> | undefined>;
attachmentListTemplate$?: Observable<
TemplateRef<AttachmentListContext> | undefined
>;
messageActionsBoxTemplate$?: Observable<
TemplateRef<MessageActionsBoxContext> | undefined
>;
messageReactionsTemplate$?: Observable<
TemplateRef<MessageReactionsContext> | undefined
>;
systemMessageTemplate$?: Observable<
TemplateRef<SystemMessageContext> | undefined
>;
popperTriggerClick = NgxPopperjsTriggers.click;
popperTriggerHover = NgxPopperjsTriggers.hover;
popperPlacementAuto = NgxPopperjsPlacements.AUTO;
Expand Down Expand Up @@ -136,7 +113,7 @@ export class MessageComponent implements OnInit, OnChanges, OnDestroy {
constructor(
private chatClientService: ChatClientService,
private channelService: ChannelService,
private customTemplatesService: CustomTemplatesService,
public customTemplatesService: CustomTemplatesService,
private cdRef: ChangeDetectorRef,
themeService: ThemeService,
private dateParser: DateParserService
Expand All @@ -155,20 +132,6 @@ export class MessageComponent implements OnInit, OnChanges, OnDestroy {
}
})
);
this.mentionTemplate$ = this.customTemplatesService.mentionTemplate$;
this.attachmentListTemplate$ =
this.customTemplatesService.attachmentListTemplate$;
this.messageActionsBoxTemplate$ =
this.customTemplatesService.messageActionsBoxTemplate$;
this.messageReactionsTemplate$ =
this.customTemplatesService.messageReactionsTemplate$;
this.deliveredStatusTemplate$ =
this.customTemplatesService.deliveredStatusTemplate$;
this.sendingStatusTemplate$ =
this.customTemplatesService.sendingStatusTemplate$;
this.readStatusTemplate$ = this.customTemplatesService.readStatusTemplate$;
this.systemMessageTemplate$ =
this.customTemplatesService.systemMessageTemplate$;
}

ngOnChanges(changes: SimpleChanges): void {
Expand Down

0 comments on commit 40b6ea5

Please sign in to comment.