mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix donwload attachment and modal to edit message
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, QueryList, SimpleChanges, TemplateRef, ViewChild, ViewChildren } from '@angular/core';
|
||||
import { AnimationController, GestureController, IonRange, ModalController, PopoverController } from '@ionic/angular';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ContactsPage } from '../contacts/contacts.page';
|
||||
@@ -26,7 +26,7 @@ import { RoomLocalRepository } from 'src/app/module/chat/data/repository/room/ro
|
||||
import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/member/member-list-local-repository.service'
|
||||
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service';
|
||||
import { EditMessagePage } from 'src/app/modals/edit-message/edit-message.page';
|
||||
import { MessageAttachmentFileType, MessageAttachmentSource, MessageEntity } from 'src/app/core/chat/entity/message';
|
||||
import { IMessageType, MessageAttachmentFileType, MessageAttachmentSource, MessageEntity } from 'src/app/core/chat/entity/message';
|
||||
import { JSFileToDataUrl } from 'src/app/utils/ToBase64';
|
||||
import { CameraService } from 'src/app/infra/camera/camera.service'
|
||||
import { FilePickerWebService } from 'src/app/infra/file-picker/web/file-picker-web.service'
|
||||
@@ -48,6 +48,9 @@ import { MemberTable } from 'src/app/infra/database/dexie/instance/chat/schema/m
|
||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { RoomTable } from 'src/app/infra/database/dexie/instance/chat/schema/room';
|
||||
import { TypingTable } from 'src/app/infra/database/dexie/instance/chat/schema/typing';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { MatMenuTrigger } from '@angular/material/menu';
|
||||
|
||||
@Component({
|
||||
selector: 'app-messages',
|
||||
@@ -144,11 +147,15 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
messages1: {[key: string]: MessageEntity[]} = {}
|
||||
MessageAttachmentFileType = MessageAttachmentFileType
|
||||
MessageAttachmentFileSource = MessageAttachmentSource
|
||||
IMessageType = IMessageType
|
||||
|
||||
@ViewChild('imageModal') imageModal: TemplateRef<any>;
|
||||
totalMembers = 0
|
||||
members: MemberTable[] = []
|
||||
|
||||
private worker: SharedWorker;
|
||||
private port: MessagePort;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
@@ -173,14 +180,55 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private userTypingLocalRepository: UserTypingLocalRepository,
|
||||
private UserTypingRemoteRepositoryService: UserTypingRemoteRepositoryService,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||
private alertController: AlertController
|
||||
private alertController: AlertController,
|
||||
private http: HttpClient
|
||||
) {
|
||||
// update
|
||||
this.checkAudioPermission()
|
||||
//this.sendChunks()
|
||||
|
||||
this.worker = new SharedWorker('shared-worker.js');
|
||||
this.port = this.worker.port;
|
||||
|
||||
this.port.onmessage = (event) => {
|
||||
console.log('Received from worker:', event.data);
|
||||
}
|
||||
|
||||
this.port.postMessage('hello');
|
||||
}
|
||||
|
||||
sendChunks() {
|
||||
const base64String = 'data:video/mp4;base64,AAAAHGZ0eXBtcDQyAAAAAGlzb21tcDQyAAACAGlzb21tcDQyaXNvbXJtZGEAAAAHZnJlZS1ybWRhAAAAGXZmY2MtbGF2ZjU4LmEyLTkyLm12NTZjAGZyZWUtcm1kYQAAAAVyZWZsYXYAAABWZGF0YTqBgIAAAAs9AAABM/f/+6mpg6z+d0+j5adJHVD+lk75p0ntRFEyTlHT/GRYbDg4ODhISEhAQK/jMCAxCBAIEwMmJgAABNmY2MtbGF2ZjU4LmEyLTkyLm12NTZjAGZyZWUtcm1kYQAAAAVyZWZsYXY=';
|
||||
const chunkSize = Math.ceil(base64String.length / 2);
|
||||
const chunks = [
|
||||
{ chunk: base64String.slice(0, chunkSize), index: 0 },
|
||||
{ chunk: base64String.slice(chunkSize), index: 1 }
|
||||
];
|
||||
|
||||
const identifier = uuidv4(); // You can set a unique identifier for the file
|
||||
|
||||
const totalChunks = chunks.length;
|
||||
|
||||
chunks.forEach((chunkData) => {
|
||||
const payload = {
|
||||
chunk: chunkData.chunk,
|
||||
identifier,
|
||||
index: chunkData.index,
|
||||
totalChunks
|
||||
};
|
||||
|
||||
this.http.post('https://gdapi-dev.dyndns.info/stage/api/v2/File/UploadBase64Chunks', payload)
|
||||
.subscribe(response => {
|
||||
console.log('Chunk sent successfully:', response);
|
||||
}, error => {
|
||||
console.error('Error sending chunk:', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
|
||||
|
||||
this.roomData$ = this.RoomLocalRepository.getRoomByIdLive(this.roomId)
|
||||
|
||||
this.roomData$.subscribe(e => {
|
||||
@@ -1387,7 +1435,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
closeModal(a: any) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user