diff --git a/src/app/pages/chat/messages/messages.page.scss b/src/app/pages/chat/messages/messages.page.scss
index 1aa3f3ce8..5db1e5a43 100644
--- a/src/app/pages/chat/messages/messages.page.scss
+++ b/src/app/pages/chat/messages/messages.page.scss
@@ -228,7 +228,6 @@
justify-content: center;
justify-content: space-evenly;
align-items: center;
- border: 1px solid red;
}
.chat-icon-options{
diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts
index 91371c520..f9140eb1e 100644
--- a/src/app/pages/chat/messages/messages.page.ts
+++ b/src/app/pages/chat/messages/messages.page.ts
@@ -40,7 +40,7 @@ import { SearchPage } from 'src/app/pages/search/search.page';
import { Storage } from '@ionic/storage';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
-import { FileOpener } from '@ionic-native/file-opener/ngx';
+import { DomSanitizer } from '@angular/platform-browser';
/* import {Plugins} from '@capacitor/core';
const { Filesystem } = Plugins; */
@@ -88,6 +88,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
storedFileNames = [];
lastAudioRecorded = '';
audioRecorded:any = "";
+ audioDownloaded:any = "";
durationDisplay = '';
duration = 0;
@ViewChild('recordbtn', { read: ElementRef }) recordBtn: ElementRef;
@@ -119,7 +120,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private processesService: ProcessesService,
private storage: Storage,
private fileToBase64Service: FileToBase64Service,
- private fileOpener: FileOpener,
+ private sanitiser: DomSanitizer,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.roomId = this.navParams.get('roomId');
@@ -131,6 +132,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
};
+ console.log(this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({}));
+
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.wsChatMethodsService.openRoom(this.roomId)
@@ -203,6 +206,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log(result);
this.storedFileNames = result.files.reverse();
this.lastAudioRecorded = this.storedFileNames[0];
+ this.getFile(this.lastAudioRecorded);
})
}
@@ -261,7 +265,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log(audioFile);
const base64sound = audioFile.data;
- //this.audioRecorded = `data:audio/aac;base64,${base64sound}`;
+ this.audioRecorded = `data:audio/aac;base64,${base64sound}`;
console.log(this.audioRecorded);
@@ -269,12 +273,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const audioRef = new Audio(`data:audio/aac;base64,${base64sound}`)
//this.audioRecorded = audioRef;
- //console.log(audioRef);
+ console.log(audioRef);
audioRef.oncanplaythrough = () => audioRef.play();
audioRef.load();
- //this.getFile(fileName);
-
}
async getFile(fileName?:any){
@@ -298,6 +300,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
+
handlePress(id?: string) {
this.selectedMsgId = id;
this.showMessageOptions = true;
@@ -425,6 +428,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
//Converting base64 to blob
const base64 = await fetch(base64sound);
const base64Response = await fetch(`data:audio/aac;base64,${base64sound}`);
+ console.log(base64Response);
+
const blob = await base64Response.blob();
console.log(blob);
@@ -434,19 +439,20 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
- "type": "audio/aac",
+ "type": "aplication/audio",
/* "guid": '', */
},
attachments: [{
"title": fileName ,
- "title_link": base64Response.url,
+ "title_link": `data:audio/aac;base64,${base64sound}`,
"title_link_download": true,
"type": "file"
}],
temporaryData: formData
})
- alert('OK')
+ this.allowTyping = true;
+ this.lastAudioRecorded = '';
}
@@ -498,6 +504,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
}
+ /* playSound(url?:any){
+ alert('here')
+ console.log(url);
+ //this.audioDownloaded = this.sanitiser.bypassSecurityTrustResourceUrl(url);
+ this.audioDownloaded = url;
+ } */
+
docIndex(index: number) {
this.dicIndex = index
}
diff --git a/src/app/pipes/pipes.module.ts b/src/app/pipes/pipes.module.ts
index f2017b539..351e00d4c 100644
--- a/src/app/pipes/pipes.module.ts
+++ b/src/app/pipes/pipes.module.ts
@@ -6,11 +6,12 @@ import { EventPipe } from './event.pipe';
import { PublicationPipe } from './publication.pipe';
import { ExpedienteTaskPipe } from './expediente-task.pipe';
import { ParticipantsPipe } from './participants.pipe';
+import { SafehtmlPipe } from './safehtml.pipe';
@NgModule({
- declarations: [FilterPipe, SearchDocumentPipe, CustomTaskPipe, EventPipe, PublicationPipe, ExpedienteTaskPipe, ParticipantsPipe],
- exports: [FilterPipe],
+ declarations: [FilterPipe, SearchDocumentPipe, CustomTaskPipe, EventPipe, PublicationPipe, ExpedienteTaskPipe, ParticipantsPipe, SafehtmlPipe],
+ exports: [FilterPipe, SafehtmlPipe],
imports: []
})
export class PipesModule { }
diff --git a/src/app/pipes/safehtml.pipe.spec.ts b/src/app/pipes/safehtml.pipe.spec.ts
new file mode 100644
index 000000000..dbc4806e0
--- /dev/null
+++ b/src/app/pipes/safehtml.pipe.spec.ts
@@ -0,0 +1,8 @@
+import { SafehtmlPipe } from './safehtml.pipe';
+
+describe('SafehtmlPipe', () => {
+ it('create an instance', () => {
+ const pipe = new SafehtmlPipe();
+ expect(pipe).toBeTruthy();
+ });
+});
diff --git a/src/app/pipes/safehtml.pipe.ts b/src/app/pipes/safehtml.pipe.ts
new file mode 100644
index 000000000..f33f62a5c
--- /dev/null
+++ b/src/app/pipes/safehtml.pipe.ts
@@ -0,0 +1,14 @@
+import { Pipe, PipeTransform } from '@angular/core';
+import { DomSanitizer } from '@angular/platform-browser';
+
+@Pipe({
+ name: 'safehtml'
+})
+export class SafehtmlPipe implements PipeTransform {
+ constructor(private sanitiser: DomSanitizer){}
+
+ transform(html): unknown {
+ return this.sanitiser.bypassSecurityTrustResourceUrl(html);
+ }
+
+}
diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts
index b93f3fea6..f80ffec0d 100644
--- a/src/app/services/chat/room.service.ts
+++ b/src/app/services/chat/room.service.ts
@@ -99,29 +99,29 @@ export class RoomService {
let ChatMessage = _ChatMessage.fields.args[0]
ChatMessage = this.fix_updatedAt(ChatMessage)
-
+
if(!this.messagesLocalReference.includes(ChatMessage.localReference)) {
const message = this.prepareMessage(ChatMessage)
this.lastMessage = message
this.calDateDuration(ChatMessage._updatedAt)
-
+
if (message.t == 'r') {
this.name = message.msg
}
-
+
if(this.isSenderIsNotMe(ChatMessage)) {
this.NativeNotificationService.sendNotificationChat({
message: message.msg,
title: this.name
});
-
+
}
-
+
this.addMessageDB(ChatMessage)
-
+
setTimeout(()=>{
this.scrollDown()
- }, 50)
+ }, 50)
}
@@ -175,7 +175,7 @@ export class RoomService {
}
async updateMessageDB(ChatMessage, localReference) {
- if (environment.chatOffline) {
+ if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
@@ -197,14 +197,14 @@ export class RoomService {
messages[index] = ChatMessage
this.storage.set('chatmsg' + this.id, messages)
}
-
+
})
}
}
async updateViewedMessage(id, userId) {
- if (environment.chatOffline) {
+ if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
@@ -212,12 +212,12 @@ export class RoomService {
let index;
const find = messages.find((message, _index)=> {
-
+
if(message._id == id) {
index = _index
return true
}
-
+
return false
})
@@ -231,7 +231,7 @@ export class RoomService {
this.storage.set('chatmsg' + this.id, messages)
}
-
+
})
}
@@ -247,15 +247,15 @@ export class RoomService {
if(!Array.isArray(messages)) {
messages = []
}
-
+
messages.forEach((message, index) => {
-
+
if(message._id == id) {
messages.splice(index, 1)
}
-
+
})
-
+
this.storage.set('chatmsg' + this.id, messages).then((value) => {
console.log('MSG SAVED ON STORAGE', value)
});
@@ -332,7 +332,7 @@ export class RoomService {
if (environment.chatOffline) {
this.messagesLocalReference.push(localReference)
this.addMessageDB(offlineChatMessage)
-
+
setTimeout(() => {
this.scrollDown()
}, 150)
@@ -347,9 +347,9 @@ export class RoomService {
/**
- *
- * @param message
- * @param ChatMessage
+ *
+ * @param message
+ * @param ChatMessage
* @description when creating message we use offline data, then we need redefined with live data
*/
redefinedMessage (message: MessageService, ChatMessage) {
@@ -497,9 +497,9 @@ export class RoomService {
/**
* @description find or create message
- * @param message
- * @param save
- * @returns
+ * @param message
+ * @param save
+ * @returns
*/
prepareMessage(message, save = true): MessageService {
message = this.fix_updatedAt(message)
@@ -515,7 +515,7 @@ export class RoomService {
const found = this.messages.find((MessageService) => {
if (MessageService._id == message._id) {
- if(this.hasLoadHistory) console.log(`${MessageService._id} == ${message._id}`)
+ if(this.hasLoadHistory) /* console.log(`${MessageService._id} == ${message._id}`) */
return true
} else {
return false
diff --git a/src/plugin/player.js b/src/plugin/player.js
new file mode 100644
index 000000000..642dc5645
--- /dev/null
+++ b/src/plugin/player.js
@@ -0,0 +1,19 @@
+{
+ class AudioPlayer extends HTMLElement{
+ constructor(){
+ super()
+
+ this.attachShadow({ mode: 'open' });
+ this.render();
+ }
+
+ render(){
+ this.shadowRoot.innerHTML = `
+
+ `;
+ }
+
+
+ }
+ customElements.define('audio-player', AudioPlayer)
+}