mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
fix chat rooms list
This commit is contained in:
@@ -254,11 +254,11 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
try {
|
try {
|
||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@@ -266,6 +266,36 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopRecording() {
|
||||||
|
this.deleteRecording();
|
||||||
|
this.allowTyping = false;
|
||||||
|
console.log('Stop');
|
||||||
|
if (!this.recording) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.recording = false;
|
||||||
|
VoiceRecorder.stopRecording().then(async (result: RecordingData) => {
|
||||||
|
console.log('==================================',result);
|
||||||
|
|
||||||
|
this.recording = false;
|
||||||
|
if (result.value && result.value.recordDataBase64) {
|
||||||
|
const recordData = result.value.recordDataBase64;
|
||||||
|
//console.log(recordData);
|
||||||
|
const fileName = new Date().getTime() + ".mp3";
|
||||||
|
//Save file
|
||||||
|
await this.storage.set('fileName',fileName)
|
||||||
|
this.storage.set('recordData',result).then(() => {
|
||||||
|
console.log('Audio recorded saved', result);
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
|
this.loadFiles();
|
||||||
|
}, 1000);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
startRecording() {
|
startRecording() {
|
||||||
console.log('Recording');
|
console.log('Recording');
|
||||||
|
|
||||||
@@ -277,32 +307,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.calculateDuration();
|
this.calculateDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
stopRecording() {
|
|
||||||
this.deleteRecording();
|
|
||||||
this.allowTyping = false;
|
|
||||||
console.log('Stop');
|
|
||||||
if (!this.recording) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.recording = false;
|
|
||||||
VoiceRecorder.stopRecording().then(async (result: RecordingData) => {
|
|
||||||
console.log(result);
|
|
||||||
this.recording = false;
|
|
||||||
if (result.value && result.value.recordDataBase64) {
|
|
||||||
const recordData = result.value.recordDataBase64;
|
|
||||||
//console.log(recordData);
|
|
||||||
const fileName = new Date().getTime() + ".mp3";
|
|
||||||
//Save file
|
|
||||||
this.storage.set('fileName',fileName);
|
|
||||||
this.storage.set('recordData',result).then(() => {
|
|
||||||
console.log('Audio recorded saved');
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
setTimeout(async () => {
|
|
||||||
this.loadFiles();
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteRecording(){
|
async deleteRecording(){
|
||||||
this.storage.remove('fileName');
|
this.storage.remove('fileName');
|
||||||
@@ -458,11 +463,11 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
audioFile = recordData;
|
audioFile = recordData;
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = recordData.value.recordDataBase64;
|
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`;
|
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Converting base64 to blob
|
//Converting base64 to blob
|
||||||
|
|||||||
@@ -208,11 +208,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
try {
|
try {
|
||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@@ -397,11 +397,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
audioFile = recordData;
|
audioFile = recordData;
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = recordData.value.recordDataBase64;
|
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`;
|
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Converting base64 to blob
|
//Converting base64 to blob
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ export class AuthService {
|
|||||||
try {
|
try {
|
||||||
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
||||||
message.file.guid = guid.path
|
message.file.guid = guid.path
|
||||||
|
|
||||||
|
console.log('========================================',guid)
|
||||||
// await this.storage.set(guid.path, message.file.image_url).then(() => {
|
// await this.storage.set(guid.path, message.file.image_url).then(() => {
|
||||||
// console.log('add picture to chat IMAGE SAVED')
|
// console.log('add picture to chat IMAGE SAVED')
|
||||||
// // message.getFileFromDb()
|
// // message.getFileFromDb()
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ export class MessageService {
|
|||||||
ts: this.attachments[0].ts
|
ts: this.attachments[0].ts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(this.attachments)
|
||||||
// save the changes to the storage
|
// save the changes to the storage
|
||||||
this.save()
|
this.save()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,13 @@ export class RoomService {
|
|||||||
|
|
||||||
console.log(_id,'==',this.messages[i]?._id, true)
|
console.log(_id,'==',this.messages[i]?._id, true)
|
||||||
this.messages.splice(i, 1)
|
this.messages.splice(i, 1)
|
||||||
|
|
||||||
|
//Get previous last message from room
|
||||||
|
const previousLastMessage = this.messages.slice(-1)[0];
|
||||||
|
this.lastMessage = previousLastMessage;
|
||||||
|
|
||||||
|
this.calDateDuration(previousLastMessage._updatedAt)
|
||||||
|
this.sortRoomList()
|
||||||
|
|
||||||
if (SessionStore.user.RochetChatUser == this.messages[i].u.username) {
|
if (SessionStore.user.RochetChatUser == this.messages[i].u.username) {
|
||||||
const allMemberThatIsOffline = this.getAllMemberThatIsOffline()
|
const allMemberThatIsOffline = this.getAllMemberThatIsOffline()
|
||||||
@@ -386,13 +393,6 @@ export class RoomService {
|
|||||||
|
|
||||||
await this.messages[i].delateDB()
|
await this.messages[i].delateDB()
|
||||||
|
|
||||||
//Get previous last message from room
|
|
||||||
const previousLastMessage = this.messages.slice(-1)[0];
|
|
||||||
|
|
||||||
this.lastMessage = previousLastMessage;
|
|
||||||
this.calDateDuration(previousLastMessage._updatedAt)
|
|
||||||
this.sortRoomList()
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -281,11 +281,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
|
|
||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@@ -447,11 +447,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
|||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
audioFile = recordData;
|
audioFile = recordData;
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = recordData.value.recordDataBase64;
|
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`;
|
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -256,11 +256,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`);
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
@@ -382,11 +382,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.storage.get('recordData').then((recordData) => {
|
this.storage.get('recordData').then((recordData) => {
|
||||||
console.log(recordData);
|
console.log(recordData);
|
||||||
audioFile = recordData;
|
audioFile = recordData;
|
||||||
if(recordData.value.recordDataBase64.includes('data:audio')){
|
if(recordData?.value?.recordDataBase64.includes('data:audio')){
|
||||||
this.audioRecorded = recordData.value.recordDataBase64;
|
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`;
|
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Converting base64 to blob
|
//Converting base64 to blob
|
||||||
|
|||||||
Reference in New Issue
Block a user