ChatStorage Done Done!

This commit is contained in:
Eudes Inácio
2022-01-21 16:55:05 +01:00
86 changed files with 458 additions and 622 deletions
+2 -2
View File
@@ -17,11 +17,11 @@
<ion-label class="title">Chat</ion-label>
</div>
<div class="div-icon">
<button class="btn-no-color" (click)="openContactsPage()">
<button title="Nova Conversa Individual" class="btn-no-color" (click)="openContactsPage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src="assets/images/icons-chat-new-conversation.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src="assets/images/theme/gov/icons-chat-new-conversation.svg"></ion-icon>
</button>
<button class="btn-no-color" (click)="openNewGroupPage()">
<button title="Novo Grupo" class="btn-no-color" (click)="openNewGroupPage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src="assets/images/icons-chat-new-group.svg" ></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src="assets/images/theme/gov/icons-chat-new-group.svg" ></ion-icon>
</button>
-3
View File
@@ -151,9 +151,6 @@ export class ChatPage implements OnInit {
this.authService.userData$.subscribe((res: any) => {
this.loggedUser = res;
console.log(this.loggedUser);
this.getDirectMessagesDB();
this.getGroupsDB()
});
this.hideRefreshButton();
@@ -112,8 +112,8 @@
<div>
<div (click)="openPreview(msg)">
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
TTTT
<img *ngIf="msg.image_url" src="{{msg.image_url}}" alt="image">
File
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
</div>
</div>
</div>
@@ -220,7 +220,7 @@
</div>
<div class="message-box width-80">
<ion-item class="ion-no-padding type-message" lines="none">
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<button hidden class="btn-no-color">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button>
@@ -748,6 +748,11 @@ downloadFileMsg(msg) {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('FILE TYPE 44', this.downloadFile)
msg.file = {
guid: msg.file.guid,
image_url: this.downloadFile,
type: msg.file.type
}
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
}
});
@@ -755,22 +760,24 @@ downloadFileMsg(msg) {
}
}
async openPreview(msg) {
if(msg.image_url != null) {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt,
}
});
modal.present();
} else {
this.downloadFileMsg(msg);
}
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
this.downloadFileMsg(msg)
} else {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
});
modal.present();
}
}
}
+10 -7
View File
@@ -61,7 +61,8 @@
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments let i = index">
<div (click)="openPreview(msg)">
<img *ngIf="msg.image_url" src={{msg.image_url}} alt="image">
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
</div>
<div>
<div>
@@ -92,7 +93,7 @@
</div>
</div>
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)" *ngIf="msg.msg !=''">
<!-- <div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)" *ngIf="msg.msg !=''">
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -101,7 +102,7 @@
<ion-label>{{msg.msg}}</ion-label>
{{last ? scrollToBottom() : ''}}
</div>
</div>
</div> -->
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.alias =='documento'">
<div class="title">
@@ -111,8 +112,10 @@
<div>
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments let i = index">
<div *ngIf="file.image_url" (click)="openPreview(msg)">
<img src="{{file.image_url}}" alt="image">
<div (click)="openPreview(msg)">
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
File
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
</div>
<div>
<div>
@@ -209,8 +212,8 @@
</div>
<div class="width-70">
<ion-item class="ion-no-padding ion-no-margin type-message" lines="none">
<ion-textarea *ngIf="!recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<ion-textarea *ngIf="recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="durationDisplay"></ion-textarea>
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" *ngIf="!recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<ion-textarea autocomplete="on" spellcheck="true" *ngIf="recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="durationDisplay"></ion-textarea>
<button hidden #recordbtn class="btn-no-color" (click)="notImplemented()">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button>
+18 -9
View File
@@ -30,6 +30,7 @@ import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { HttpEventType } from '@angular/common/http';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
import { MessageService } from 'src/app/services/chat/message.service';
const IMAGE_DIR = 'stored-images';
@@ -131,7 +132,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
directory: Directory.Data,
recursive: true
});
this.getRoomMessageDB(this.roomId);
}
ngAfterViewInit() {
@@ -782,7 +782,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
card.el.style['z-index'] = 11;
}
downloadFileMsg(msg) {
downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
@@ -795,30 +795,39 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('FILE TYPE 44', this.downloadFile)
msg.file = {
guid: msg.file.guid,
image_url: this.downloadFile,
type: msg.file.type
}
this.sqlservice.updateChatMsg(msg._id, this.downloadFile);
}
});
console.log('FILE TYPE 44', this.downloadFile)
}
}
async openPreview(msg) {
if(msg.image_url != null) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
this.downloadFileMsg(msg)
} else {
const modal = await this.modalController.create({
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.image_url,
image: msg.file.image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt,
_updatedAt: msg._updatedAt
}
});
modal.present();
} else {
this.downloadFileMsg(msg);
}
}