|
| 1 | +@using MudExtensions.Enums |
1 | 2 | @inject IChatService ChatService
|
2 | 3 | @inject IProfileCache ProfileCache
|
3 | 4 | @inject ISnackbar Snackbar
|
|
81 | 82 | }
|
82 | 83 |
|
83 | 84 | </Virtualize>
|
84 |
| - @if (LastMessageWasSentSuccessfully) |
85 |
| - { |
86 |
| - <div title="Din besked er blevet sendt" class="message-sent-successfully-container"> |
87 |
| - <MudIcon Icon="@Icons.Material.Outlined.CheckCircleOutline" |
88 |
| - Class="message-sent-successfully" /> |
89 |
| - </div> |
90 |
| - } |
| 85 | + |
| 86 | + <MudAnimate @ref="_messageSuccessfullySentAnimation" |
| 87 | + AnimationType="AnimationType.Fade" |
| 88 | + AnimationTiming="AnimationTiming.EaseIn" |
| 89 | + Delay="500" |
| 90 | + Selector=".message-sent-successfully-container" /> |
| 91 | + |
| 92 | + <div title="Din besked er blevet sendt" class="message-sent-successfully-container"> |
| 93 | + <MudIcon Icon="@Icons.Material.Outlined.CheckCircleOutline" |
| 94 | + Class="message-sent-successfully" /> |
| 95 | + </div> |
91 | 96 |
|
92 | 97 | <MudTextField @bind-Value="_userText"
|
93 | 98 | FullWidth
|
|
109 | 114 |
|
110 | 115 | </MudLoading>
|
111 | 116 | @code {
|
| 117 | + // TODO: Select currently displayed chat using this, when we update to dotnet 8 |
| 118 | + [SupplyParameterFromQuery] |
| 119 | + public Guid? ChatId { get; set; } |
| 120 | + |
112 | 121 | private UserProfile? _currentUser;
|
113 | 122 | private UserSlim _currentUserSlim = null!;
|
114 | 123 | private List<ChatDto> _chats = new();
|
|
119 | 128 | private bool _isActiveChatPublished = true;
|
120 | 129 | private bool _isLoading = true;
|
121 | 130 |
|
| 131 | + private MudAnimate _messageSuccessfullySentAnimation = null!; |
122 | 132 | private Dictionary<Guid, Guid> _lastSuccessfullySentMessageForChat = new();
|
123 | 133 | private bool LastMessageWasSentSuccessfully
|
124 | 134 | {
|
|
142 | 152 | }
|
143 | 153 | }
|
144 | 154 |
|
145 |
| - // TODO: Select currently displayed chat using this, when we update to dotnet 8 |
146 |
| - [SupplyParameterFromQuery] |
147 |
| - public Guid? ChatId { get; set; } |
148 |
| - |
149 | 155 | protected override async Task OnInitializedAsync()
|
150 | 156 | {
|
151 | 157 | _currentUser = await ProfileCache.GetOrCreateProfileAsync();
|
|
183 | 189 | if (message.SenderId == _currentUser.Id)
|
184 | 190 | {
|
185 | 191 | _lastSuccessfullySentMessageForChat[chat.Id] = message.Id;
|
| 192 | + StateHasChanged(); |
| 193 | + await _messageSuccessfullySentAnimation.Refresh(); |
186 | 194 | return;
|
187 | 195 | }
|
188 | 196 |
|
|
321 | 329 | _chats.Insert(0, newChat);
|
322 | 330 |
|
323 | 331 | _isActiveChatPublished = false;
|
324 |
| - |
325 | 332 | await SelectChat(newChat);
|
326 | 333 | }
|
327 | 334 |
|
328 | 335 | private string GetRecipientsProfilePictureUrl(ChatMessageDto message)
|
329 |
| - { |
330 |
| - return _activeChat?.Recipients.FirstOrDefault(recipient => recipient.Id == message.SenderId)?.ProfilePictureUrl ?? ProfileConstants.Default_Profile_Picture; |
331 |
| - } |
332 |
| - |
| 336 | + => _activeChat? |
| 337 | + .Recipients |
| 338 | + .FirstOrDefault(recipient => recipient.Id == message.SenderId)?.ProfilePictureUrl |
| 339 | + ?? ProfileConstants.Default_Profile_Picture; |
333 | 340 | }
|
0 commit comments