further improvements

This commit is contained in:
tiago.kayaya
2021-09-23 12:13:20 +01:00
parent ccd211140a
commit 07cbb237e4
20 changed files with 249 additions and 111 deletions
@@ -8,12 +8,14 @@ import { MessagesPageRoutingModule } from './messages-routing.module';
import { MessagesPage } from './messages.page';
import { SharedModule } from 'src/app/shared/shared.module';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
FontAwesomeModule,
MessagesPageRoutingModule
],
exports: [MessagesPage],
+19 -11
View File
@@ -42,18 +42,26 @@
<div *ngIf="msg.attachments" class="message-attachments">
<div *ngFor="let file of msg.attachments">
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
<div>
<div class="file d-flex">
<ion-thumbnail *ngIf="file.thumb_url" slot="start">
<img src="{{file.thumb_url}}" alt="image">
</ion-thumbnail>
<!-- <canvas id="pdf_canvas"></canvas> -->
<ion-label class="file-details">
<h3 (click)="viewDocument(file.title_link)" class="file-title cursor-pointer">{{file.title}}</h3>
<p *ngIf="file.text">{{file.text}}</p>
</ion-label>
<div>
<div class="file">
<!-- <canvas id="pdf_canvas"></canvas> -->
<ion-label class="file-details" *ngIf="msg.file">
<span (click)="viewDocument(file.title_link)" class="file-title cursor-pointer">
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
{{file.title}}
</span>
</ion-label>
</div>
<div class="file-details-optional">
<ion-label *ngIf="msg.file">
<span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
</ion-label>
</div>
</div>
</div>
</div>
</div>
{{last ? scrollToBottom() : ''}}
@@ -151,7 +151,29 @@
margin-left: 10px;
float: right;
}
}
}
.message{
.message-attachments{
.file{
align-items: center;
.file-details{
width: 100%;
.file-title{
color: #000;
text-decoration: underline;
white-space: nowrap;
overflow: hidden !important;
text-overflow: ellipsis !important;
}
.file-title:hover{
color: #0782c9;
}
}
}
}
}
}
ion-footer{
+27 -17
View File
@@ -139,6 +139,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.scrollingOnce = false;
}
this.currentPosition = scroll;
/* console.log(this.currentPosition);
console.log(this.scrollingOnce); */
}
ngOnDestroy() {
@@ -356,6 +358,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
this.openNewEventPage.emit(data);
}
else if(res['data'] == 'take-picture'){
this.fileService.addCameraPictureToChat(this.roomId);
//this.loadPicture();
}
else if(res['data'] == 'add-picture'){
this.fileService.addPictureToChat(this.roomId);
//this.loadPicture();
@@ -376,38 +382,42 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async serverLongPull() {
const roomId = this.roomId
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
const roomId = this.roomId;
if (res == 502) {
// Connection timeout
// happens when the connection was pending for too long
// let's reconnect
await this.serverLongPull();
} else if (res != 200) {
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
console.log(res['success']);
if (res['success'] == true) {
// Show Error
//showMessage(response.statusText);
//this.loadMessages()
this.messages = res['messages'].reverse();
this.chatMessageStore.add(roomId, this.messages)
console.log(this.messages);
// Reconnect in one second
if(this.route.url != "/home/chat"){
console.log("Timer message stop")
} else {
if(document.querySelector('app-messages')){
await new Promise(resolve => setTimeout(resolve, 5000));
await this.serverLongPull();
this.getDirectMessages.emit();
console.log('Timer message running')
}
}
} else {
else{
if(document.querySelector('app-messages')){
await new Promise(resolve => setTimeout(resolve, 5000));
await this.serverLongPull();
this.getDirectMessages.emit();
console.log('Timer message running')
}
}
} /* else {
// Got message
//let message = await response.text();
//this.loadMessages()
await this.serverLongPull();
}
} */
}, (error)=>{
console.log(error);
this.serverLongPull();
});
}