11import { ModalWindowStateService } from '../../services/states/modalWindowState.service' ;
2- import {
3- Component ,
4- OnChanges ,
5- OnDestroy ,
6- OnInit ,
7- Sanitizer ,
8- SecurityContext ,
9- SimpleChanges
10- } from '@angular/core' ;
2+ import { Component , OnDestroy , OnInit } from '@angular/core' ;
113import { TokensService } from '../../services/messenger/tokens.service' ;
124import { Chat } from '../../types/models/Chat' ;
135import { CommunitiesService } from '../../services/api/communities.service' ;
@@ -23,21 +15,13 @@ import { ValidationService } from '../../services/messenger/validation.service';
2315import * as signalR from '@microsoft/signalr' ;
2416import { EditMessageNotification } from '../../types/models/EditMessageNotification' ;
2517import { DeleteMessageNotification } from '../../types/models/DeleteMessageNotification' ;
26- import {
27- Subject ,
28- takeUntil ,
29- of ,
30- BehaviorSubject ,
31- firstValueFrom ,
32- distinctUntilKeyChanged
33- } from 'rxjs' ;
18+ import { Subject , takeUntil , BehaviorSubject , firstValueFrom , distinctUntilKeyChanged } from 'rxjs' ;
3419import { DisplayNameColours } from 'src/app/types/enums/DisplayNameColours' ;
3520import { DeleteMessageCommand } from 'src/app/types/requests/DeleteMessageCommand' ;
3621import ApiBaseService from 'src/app/services/api/apiBase.service' ;
3722import { SendMessageResponse } from '../../types/responses/SendMessageResponse' ;
3823import { ReplyStateSerivce } from 'src/app/services/states/replyState.service' ;
3924import { Reply } from 'src/app/types/models/Reply' ;
40- import { DomSanitizer , SafeUrl } from '@angular/platform-browser' ;
4125
4226@Component ( {
4327 selector : 'app-chats' ,
@@ -87,13 +71,12 @@ export class ChatsComponent implements OnInit, OnDestroy {
8771 title : ''
8872 } ;
8973
90- public activeChatId : string = '' ;
74+ public activeChatId = '' ;
9175 public messages : Message [ ] = [ ] ;
9276
9377 public messageAttachment : File | null = null ;
9478 public messageAttachmentBlobUrl : string | ArrayBuffer | null = '' ;
9579 public messageText = '' ;
96- public messageAttachmentUrl : string = '' ;
9780 public searchChatQuery = '' ;
9881 public searchMessagesQuery = '' ;
9982 public chatFilter = 'All chats' ;
@@ -111,13 +94,11 @@ export class ChatsComponent implements OnInit, OnDestroy {
11194 }
11295
11396 initializeView ( ) : void {
114- this . activeChatBehaviorSubject
115- . pipe ( distinctUntilKeyChanged ( 'chatId' ) )
116- . subscribe ( ( ) => {
117- this . _replyStateService . setReplyNull ( )
118- this . messageAttachment = null
119- this . messageAttachmentBlobUrl = null
120- } ) ;
97+ this . activeChatBehaviorSubject . pipe ( distinctUntilKeyChanged ( 'chatId' ) ) . subscribe ( ( ) => {
98+ this . _replyStateService . setReplyNull ( ) ;
99+ this . messageAttachment = null ;
100+ this . messageAttachmentBlobUrl = null ;
101+ } ) ;
121102
122103 const tokens = this . _tokensService . getTokens ( ) ;
123104
@@ -189,12 +170,11 @@ export class ChatsComponent implements OnInit, OnDestroy {
189170 async imageSelected ( event : any ) {
190171 this . messageAttachment = event . target . files [ 0 ] ;
191172
192- var reader = new FileReader ( ) ;
193- reader . onload = ( ) => {
194- console . log ( reader . result ) ;
195- this . messageAttachmentBlobUrl = reader . result
196- } ;
197- reader . readAsDataURL ( event . target . files [ 0 ] ) ;
173+ const reader = new FileReader ( ) ;
174+ reader . onload = ( ) => {
175+ this . messageAttachmentBlobUrl = reader . result ;
176+ } ;
177+ reader . readAsDataURL ( event . target . files [ 0 ] ) ;
198178 }
199179
200180 removeImageSelected ( ) {
0 commit comments