|
15 | 15 | data-testid="message-container" |
16 | 16 | > |
17 | 17 | <ng-container *ngIf="!message?.deleted_at; else deletedMessage"> |
18 | | - <ng-container |
19 | | - *ngIf=" |
20 | | - isSentByCurrentUser && |
21 | | - ((isLastSentMessage && message?.status === 'received') || |
22 | | - message?.status === 'sending') |
23 | | - " |
24 | | - > |
25 | | - <ng-container *ngIf="message?.status === 'sending'; else sentStatus"> |
26 | | - <ng-container *ngTemplateOutlet="sendingStatus"></ng-container> |
27 | | - </ng-container> |
28 | | - <ng-template #sentStatus> |
29 | | - <ng-container *ngIf="isMessageDeliveredAndRead; else deliveredStatus"> |
30 | | - <ng-container *ngTemplateOutlet="readStatus"></ng-container> |
31 | | - </ng-container> |
32 | | - </ng-template> |
33 | | - </ng-container> |
34 | | - <stream-avatar |
35 | | - data-testid="avatar" |
36 | | - class="str-chat-angular__avatar-host" |
37 | | - [imageUrl]="message?.user?.image" |
38 | | - [name]="message?.user?.name || message?.user?.id" |
39 | | - ></stream-avatar> |
40 | | - <div class="str-chat__message-inner"> |
41 | | - <div |
42 | | - class="str-chat__message-simple__actions" |
43 | | - data-testid="message-options" |
44 | | - *ngIf="areOptionsVisible" |
| 18 | + <ng-container *ngIf="message?.type !== 'system'; else systemMessage"> |
| 19 | + <ng-container |
| 20 | + *ngIf=" |
| 21 | + isSentByCurrentUser && |
| 22 | + ((isLastSentMessage && message?.status === 'received') || |
| 23 | + message?.status === 'sending') |
| 24 | + " |
45 | 25 | > |
| 26 | + <ng-container *ngIf="message?.status === 'sending'; else sentStatus"> |
| 27 | + <ng-container *ngTemplateOutlet="sendingStatus"></ng-container> |
| 28 | + </ng-container> |
| 29 | + <ng-template #sentStatus> |
| 30 | + <ng-container *ngIf="isMessageDeliveredAndRead; else deliveredStatus"> |
| 31 | + <ng-container *ngTemplateOutlet="readStatus"></ng-container> |
| 32 | + </ng-container> |
| 33 | + </ng-template> |
| 34 | + </ng-container> |
| 35 | + <stream-avatar |
| 36 | + data-testid="avatar" |
| 37 | + class="str-chat-angular__avatar-host" |
| 38 | + [imageUrl]="message?.user?.image" |
| 39 | + [name]="message?.user?.name || message?.user?.id" |
| 40 | + ></stream-avatar> |
| 41 | + <div class="str-chat__message-inner"> |
46 | 42 | <div |
47 | | - class=" |
48 | | - str-chat__message-simple__actions__action |
49 | | - str-chat__message-simple__actions__action--options |
50 | | - " |
51 | | - > |
52 | | - <stream-message-actions-box |
53 | | - [isOpen]="isActionBoxOpen" |
54 | | - [isMine]="isSentByCurrentUser" |
55 | | - [enabledActions]="enabledMessageActions" |
56 | | - [message]="message" |
57 | | - (displayedActionsCount)="visibleMessageActionsCount = $event" |
58 | | - ></stream-message-actions-box> |
59 | | - <stream-icon |
60 | | - *ngIf="visibleMessageActionsCount > 0" |
61 | | - data-testid="action-icon" |
62 | | - icon="action-icon" |
63 | | - (keyup.enter)="isActionBoxOpen = !isActionBoxOpen" |
64 | | - (click)="isActionBoxOpen = !isActionBoxOpen" |
65 | | - ></stream-icon> |
66 | | - </div> |
67 | | - <div |
68 | | - *ngIf="areReactionsEnabled" |
69 | | - class=" |
70 | | - str-chat__message-simple__actions__action |
71 | | - str-chat__message-simple__actions__action--reactions |
72 | | - " |
73 | | - data-testid="reaction-icon" |
74 | | - (click)="isReactionSelectorOpen = !isReactionSelectorOpen" |
75 | | - (keyup.enter)="isReactionSelectorOpen = !isReactionSelectorOpen" |
76 | | - > |
77 | | - <stream-icon icon="reaction-icon"></stream-icon> |
78 | | - </div> |
79 | | - </div> |
80 | | - <stream-message-reactions |
81 | | - *ngIf="areReactionsEnabled" |
82 | | - [messageReactionCounts]="message?.reaction_counts || {}" |
83 | | - [latestReactions]="message?.latest_reactions || []" |
84 | | - [(isSelectorOpen)]="isReactionSelectorOpen" |
85 | | - [messageId]="message?.id" |
86 | | - [ownReactions]="message?.own_reactions || []" |
87 | | - ></stream-message-reactions> |
88 | | - <stream-attachment-list |
89 | | - *ngIf="hasAttachment" |
90 | | - [attachments]="message!.attachments!" |
91 | | - ></stream-attachment-list> |
92 | | - <div class="str-chat__message-text" *ngIf="message?.text"> |
93 | | - <div |
94 | | - data-testid="inner-message" |
95 | | - class=" |
96 | | - str-chat__message-text-inner str-chat__message-simple-text-inner |
97 | | - " |
98 | | - [class.str-chat__message-light-text-inner--has-attachment]=" |
99 | | - hasAttachment |
100 | | - " |
101 | | - (click)=" |
102 | | - message?.status === 'failed' && message?.errorStatusCode !== 403 |
103 | | - ? resendMessage() |
104 | | - : undefined |
105 | | - " |
106 | | - (keyup.enter)=" |
107 | | - message?.status === 'failed' && message?.errorStatusCode !== 403 |
108 | | - ? resendMessage() |
109 | | - : undefined |
110 | | - " |
| 43 | + class="str-chat__message-simple__actions" |
| 44 | + data-testid="message-options" |
| 45 | + *ngIf="areOptionsVisible" |
111 | 46 | > |
112 | 47 | <div |
113 | | - data-testid="client-error-message" |
114 | | - *ngIf="message?.type === 'error'" |
115 | | - class="str-chat__simple-message--error-message" |
| 48 | + class=" |
| 49 | + str-chat__message-simple__actions__action |
| 50 | + str-chat__message-simple__actions__action--options |
| 51 | + " |
116 | 52 | > |
117 | | - {{ "streamChat.Error · Unsent" | translate }} |
| 53 | + <stream-message-actions-box |
| 54 | + [isOpen]="isActionBoxOpen" |
| 55 | + [isMine]="isSentByCurrentUser" |
| 56 | + [enabledActions]="enabledMessageActions" |
| 57 | + [message]="message" |
| 58 | + (displayedActionsCount)="visibleMessageActionsCount = $event" |
| 59 | + ></stream-message-actions-box> |
| 60 | + <stream-icon |
| 61 | + *ngIf="visibleMessageActionsCount > 0" |
| 62 | + data-testid="action-icon" |
| 63 | + icon="action-icon" |
| 64 | + (keyup.enter)="isActionBoxOpen = !isActionBoxOpen" |
| 65 | + (click)="isActionBoxOpen = !isActionBoxOpen" |
| 66 | + ></stream-icon> |
118 | 67 | </div> |
119 | 68 | <div |
120 | | - data-testid="error-message" |
121 | | - *ngIf="message?.status === 'failed'" |
122 | | - class="str-chat__simple-message--error-message" |
| 69 | + *ngIf="areReactionsEnabled" |
| 70 | + class=" |
| 71 | + str-chat__message-simple__actions__action |
| 72 | + str-chat__message-simple__actions__action--reactions |
| 73 | + " |
| 74 | + data-testid="reaction-icon" |
| 75 | + (click)="isReactionSelectorOpen = !isReactionSelectorOpen" |
| 76 | + (keyup.enter)="isReactionSelectorOpen = !isReactionSelectorOpen" |
123 | 77 | > |
124 | | - {{ |
125 | | - (message?.errorStatusCode === 403 |
126 | | - ? "streamChat.Message Failed · Unauthorized" |
127 | | - : "streamChat.Message Failed · Click to try again" |
128 | | - ) | translate |
129 | | - }} |
| 78 | + <stream-icon icon="reaction-icon"></stream-icon> |
130 | 79 | </div> |
| 80 | + </div> |
| 81 | + <stream-message-reactions |
| 82 | + *ngIf="areReactionsEnabled" |
| 83 | + [messageReactionCounts]="message?.reaction_counts || {}" |
| 84 | + [latestReactions]="message?.latest_reactions || []" |
| 85 | + [(isSelectorOpen)]="isReactionSelectorOpen" |
| 86 | + [messageId]="message?.id" |
| 87 | + [ownReactions]="message?.own_reactions || []" |
| 88 | + ></stream-message-reactions> |
| 89 | + <stream-attachment-list |
| 90 | + *ngIf="hasAttachment" |
| 91 | + [attachments]="message!.attachments!" |
| 92 | + ></stream-attachment-list> |
| 93 | + <div class="str-chat__message-text" *ngIf="message?.text"> |
131 | 94 | <div |
132 | | - (click)="textClicked()" |
133 | | - (keyup.enter)="textClicked()" |
134 | | - data-testid="text" |
135 | | - [innerHTML]="message?.html || message?.text" |
136 | | - ></div> |
| 95 | + data-testid="inner-message" |
| 96 | + class=" |
| 97 | + str-chat__message-text-inner str-chat__message-simple-text-inner |
| 98 | + " |
| 99 | + [class.str-chat__message-light-text-inner--has-attachment]=" |
| 100 | + hasAttachment |
| 101 | + " |
| 102 | + (click)=" |
| 103 | + message?.status === 'failed' && message?.errorStatusCode !== 403 |
| 104 | + ? resendMessage() |
| 105 | + : undefined |
| 106 | + " |
| 107 | + (keyup.enter)=" |
| 108 | + message?.status === 'failed' && message?.errorStatusCode !== 403 |
| 109 | + ? resendMessage() |
| 110 | + : undefined |
| 111 | + " |
| 112 | + > |
| 113 | + <div |
| 114 | + data-testid="client-error-message" |
| 115 | + *ngIf="message?.type === 'error'" |
| 116 | + class="str-chat__simple-message--error-message" |
| 117 | + > |
| 118 | + {{ "streamChat.Error · Unsent" | translate }} |
| 119 | + </div> |
| 120 | + <div |
| 121 | + data-testid="error-message" |
| 122 | + *ngIf="message?.status === 'failed'" |
| 123 | + class="str-chat__simple-message--error-message" |
| 124 | + > |
| 125 | + {{ |
| 126 | + (message?.errorStatusCode === 403 |
| 127 | + ? "streamChat.Message Failed · Unauthorized" |
| 128 | + : "streamChat.Message Failed · Click to try again" |
| 129 | + ) | translate |
| 130 | + }} |
| 131 | + </div> |
| 132 | + <div |
| 133 | + (click)="textClicked()" |
| 134 | + (keyup.enter)="textClicked()" |
| 135 | + data-testid="text" |
| 136 | + [innerHTML]="message?.html || message?.text" |
| 137 | + ></div> |
| 138 | + </div> |
| 139 | + </div> |
| 140 | + <div class="str-chat__message-data str-chat__message-simple-data"> |
| 141 | + <span |
| 142 | + data-testid="sender" |
| 143 | + *ngIf="!isSentByCurrentUser" |
| 144 | + class="str-chat__message-simple-name" |
| 145 | + > |
| 146 | + {{ message?.user?.name ? message?.user?.name : message?.user?.id }} |
| 147 | + </span> |
| 148 | + <span data-testid="date" class="str-chat__message-simple-timestamp"> |
| 149 | + {{ parsedDate }} |
| 150 | + </span> |
137 | 151 | </div> |
138 | 152 | </div> |
139 | | - <div class="str-chat__message-data str-chat__message-simple-data"> |
140 | | - <span |
141 | | - data-testid="sender" |
142 | | - *ngIf="!isSentByCurrentUser" |
143 | | - class="str-chat__message-simple-name" |
144 | | - > |
145 | | - {{ message?.user?.name ? message?.user?.name : message?.user?.id }} |
146 | | - </span> |
147 | | - <span data-testid="date" class="str-chat__message-simple-timestamp"> |
148 | | - {{ parsedDate }} |
149 | | - </span> |
150 | | - </div> |
151 | | - </div> |
| 153 | + </ng-container> |
152 | 154 | </ng-container> |
153 | 155 | </div> |
154 | 156 |
|
|
205 | 207 | </div> |
206 | 208 | </div> |
207 | 209 | </ng-template> |
| 210 | + |
| 211 | +<ng-template #systemMessage> |
| 212 | + <div data-testid="system-message" class="str-chat__message--system"> |
| 213 | + <div class="str-chat__message--system__text"> |
| 214 | + <div class="str-chat__message--system__line"></div> |
| 215 | + <p>{{ message?.text }}</p> |
| 216 | + <div class="str-chat__message--system__line"></div> |
| 217 | + </div> |
| 218 | + <div class="str-chat__message--system__date"> |
| 219 | + {{ parsedDate }} |
| 220 | + </div> |
| 221 | + </div> |
| 222 | +</ng-template> |
0 commit comments