mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
direct message
This commit is contained in:
@@ -21,7 +21,7 @@ export class RoomSocketRepositoryService {
|
|||||||
|
|
||||||
listenToCreateRoom() {
|
listenToCreateRoom() {
|
||||||
return this.socket.getData().pipe(
|
return this.socket.getData().pipe(
|
||||||
filter((data) => data.method == 'UserAddGroup')
|
filter((data) => data?.method == 'UserAddGroup')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,24 +41,24 @@ export const MessageEntitySchema = z.object({
|
|||||||
|
|
||||||
type Message = z.infer<typeof MessageEntitySchema>;
|
type Message = z.infer<typeof MessageEntitySchema>;
|
||||||
|
|
||||||
export class MessageEntity implements Message {
|
export class MessageEntity {
|
||||||
|
|
||||||
$id: number
|
$id?: number
|
||||||
id: string
|
id?: string
|
||||||
roomId?: string
|
roomId?: string
|
||||||
receiverId?: number
|
receiverId?: number
|
||||||
message: string
|
message?: string
|
||||||
messageType: number = 0
|
messageType: number = 0
|
||||||
canEdit: boolean = false
|
canEdit: boolean = false
|
||||||
oneShot: boolean = false
|
oneShot: boolean = false
|
||||||
sentAt: string
|
sentAt?: string
|
||||||
requireUnlock: boolean = false
|
requireUnlock: boolean = false
|
||||||
info: {
|
info: {
|
||||||
memberId?: number
|
memberId?: number
|
||||||
readAt?: string,
|
readAt?: string,
|
||||||
deliverAt?: string
|
deliverAt?: string
|
||||||
}[] = []
|
}[] = []
|
||||||
sender: {
|
sender!: {
|
||||||
wxUserId: number,
|
wxUserId: number,
|
||||||
wxFullName: string,
|
wxFullName: string,
|
||||||
wxeMail: string,
|
wxeMail: string,
|
||||||
@@ -82,7 +82,7 @@ export class MessageEntity implements Message {
|
|||||||
|
|
||||||
reactions = []
|
reactions = []
|
||||||
|
|
||||||
requestId: string
|
requestId!: string
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { err, ok } from 'neverthrow';
|
import { err, ok } from 'neverthrow';
|
||||||
import { SessionStore } from 'src/app/store/session.service';
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
import { MessageLocalDataSourceService } from '../../data/repository/message/message-local-data-source.service';
|
import { MessageLocalDataSourceService } from '../../data/repository/message/message-local-data-source.service';
|
||||||
|
import { MessageSocketRepositoryService } from '../../data/repository/message/message-live-signalr-data-source.service';
|
||||||
import { MessageRemoteDataSourceService } from '../../data/repository/message/message-remote-data-source.service';
|
import { MessageRemoteDataSourceService } from '../../data/repository/message/message-remote-data-source.service';
|
||||||
import { SignalRService } from '../../infra/socket/signal-r.service';
|
import { SignalRService } from '../../infra/socket/signal-r.service';
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ import { SignalRService } from '../../infra/socket/signal-r.service';
|
|||||||
export class MessageReadAtByIdUseCaseService {
|
export class MessageReadAtByIdUseCaseService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private messageRemoteDataSourceService: MessageRemoteDataSourceService,
|
private MessageSocketRepositoryService: MessageSocketRepositoryService,
|
||||||
private messageLiveSignalRDataSourceService: SignalRService,
|
private messageLiveSignalRDataSourceService: SignalRService,
|
||||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||||
) { }
|
) { }
|
||||||
@@ -21,7 +22,7 @@ export class MessageReadAtByIdUseCaseService {
|
|||||||
if(result.isOk()) {
|
if(result.isOk()) {
|
||||||
if(result.value) {
|
if(result.value) {
|
||||||
|
|
||||||
return await this.messageLiveSignalRDataSourceService.sendReadAt({roomId, memberId: SessionStore.user.UserId, chatMessageId: result.value.id})
|
return await this.MessageSocketRepositoryService.sendReadAt({roomId, memberId: SessionStore.user.UserId, messageId: result.value.id, requestId: ''})
|
||||||
}
|
}
|
||||||
return ok(true)
|
return ok(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ export class SocketJoinUseCaseService {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|
||||||
execute() {}
|
execute() {
|
||||||
|
|
||||||
|
this.MessageSocketRepositoryService.sendDirectMessage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject, Observable, Subject, timer } from 'rxjs';
|
import { BehaviorSubject, Observable, Subject, timer } from 'rxjs';
|
||||||
import { Platform } from '@ionic/angular';
|
import { Platform } from '@ionic/angular';
|
||||||
import { SignalRConnection } from './signalR';
|
import { SignalRConnection, SocketMessage } from './signalR';
|
||||||
import { Plugins } from '@capacitor/core';
|
import { Plugins } from '@capacitor/core';
|
||||||
import { UserTypingDTO } from '../../data/dto/typing/typingInputDTO';
|
import { UserTypingDTO } from '../../data/dto/typing/typingInputDTO';
|
||||||
import { MessageOutPutDataDTO } from '../../data/dto/message/messageOutputDTO';
|
import { MessageOutPutDataDTO } from '../../data/dto/message/messageOutputDTO';
|
||||||
import { MessageDeleteInputDTO } from '../../data/dto/message/messageDeleteInputDTO';
|
import { MessageDeleteInputDTO } from '../../data/dto/message/messageDeleteInputDTO';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { filter, map, switchMap } from 'rxjs/operators';
|
||||||
import { Result } from 'neverthrow';
|
import { Result } from 'neverthrow';
|
||||||
import { HubConnection } from '@microsoft/signalr';
|
import { HubConnection } from '@microsoft/signalr';
|
||||||
|
|
||||||
@@ -28,11 +28,7 @@ export type ISignalRInput = z.infer<typeof SignalRInputSchema>;
|
|||||||
})
|
})
|
||||||
export class SignalRService {
|
export class SignalRService {
|
||||||
private connection: SignalRConnection;
|
private connection: SignalRConnection;
|
||||||
private messageSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
|
||||||
private typingSubject: BehaviorSubject<UserTypingDTO> = new BehaviorSubject<UserTypingDTO>(null);
|
|
||||||
private connectingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(null);
|
private connectingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(null);
|
||||||
private messageDelete: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
|
||||||
private messageUpdateSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
|
||||||
private sendDataSubject: BehaviorSubject<{method: string, data: any}> = new BehaviorSubject<{method: string, data: any}>(null);
|
private sendDataSubject: BehaviorSubject<{method: string, data: any}> = new BehaviorSubject<{method: string, data: any}>(null);
|
||||||
|
|
||||||
private deadConnectionBackGround: Subject<any>;
|
private deadConnectionBackGround: Subject<any>;
|
||||||
@@ -80,24 +76,6 @@ export class SignalRService {
|
|||||||
this.connection?.closeConnection()
|
this.connection?.closeConnection()
|
||||||
this.connection = connection
|
this.connection = connection
|
||||||
|
|
||||||
this.connection.getSendLater().subscribe(data => {
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
this.connection.getMessages().subscribe((data) => {
|
|
||||||
this.messageSubject.next(data)
|
|
||||||
})
|
|
||||||
this.connection.getTyping().subscribe((data) => {
|
|
||||||
this.typingSubject.next(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
this.connection.getMessageDelete().subscribe((data) => {
|
|
||||||
this.messageDelete.next(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
this.connection.getMessageUpdateSubject().subscribe((data) => {
|
|
||||||
this.messageUpdateSubject.next(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
this.connection.getData().subscribe((data) => {
|
this.connection.getData().subscribe((data) => {
|
||||||
this.sendDataSubject.next(data)
|
this.sendDataSubject.next(data)
|
||||||
@@ -123,20 +101,36 @@ export class SignalRService {
|
|||||||
|
|
||||||
|
|
||||||
getMessage() {
|
getMessage() {
|
||||||
return this.messageSubject.asObservable()
|
return this.getData().pipe(
|
||||||
|
filter((e) : e is SocketMessage<MessageOutPutDataDTO>=> e?.method == 'ReceiveMessage'
|
||||||
|
),
|
||||||
|
map((e)=> e.data)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getTyping() {
|
getTyping() {
|
||||||
return this.typingSubject.asObservable().pipe()
|
return this.getData().pipe(
|
||||||
|
filter((e) : e is SocketMessage<UserTypingDTO>=> e?.method == 'TypingMessage'
|
||||||
|
),
|
||||||
|
map((e)=> e.data)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getMessageDelete() {
|
getMessageDelete() {
|
||||||
return this.messageDelete.asObservable()
|
return this.getData().pipe(
|
||||||
|
filter((e) : e is SocketMessage<MessageOutPutDataDTO>=> e?.method == 'DeleteMessage'
|
||||||
|
),
|
||||||
|
map((e)=> e.data)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getMessageUpdate() {
|
getMessageUpdate() {
|
||||||
return this.messageUpdateSubject.asObservable()
|
return this.getData().pipe(
|
||||||
|
filter((e) : e is SocketMessage<MessageOutPutDataDTO>=> e?.method == 'UpdateMessage'
|
||||||
|
),
|
||||||
|
map((e)=> e.data)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
sendData<T>(input: ISignalRInput) {
|
sendData<T>(input: ISignalRInput) {
|
||||||
@@ -159,9 +153,6 @@ export class SignalRService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async sendReadAt({ roomId, memberId, chatMessageId}) {
|
|
||||||
return await this.connection.sendReadAt({ roomId, memberId, chatMessageId})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ export class SignalRConnection {
|
|||||||
|
|
||||||
private hubConnection: signalR.HubConnection;
|
private hubConnection: signalR.HubConnection;
|
||||||
private messageSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
private messageSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
||||||
private messageDelete: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
|
||||||
private messageUPdateSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
|
||||||
private typingSubject: BehaviorSubject<UserTypingDTO> = new BehaviorSubject<UserTypingDTO>(null);
|
|
||||||
private readAtSubject: BehaviorSubject<string> = new BehaviorSubject<any>(null);
|
|
||||||
private connectionStateSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
private connectionStateSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||||
private disconnectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
private disconnectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||||
private reconnectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
private reconnectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||||
@@ -111,36 +107,6 @@ export class SignalRConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async sendReadAt(data: Object & { roomId, memberId, chatMessageId}):Promise<Result<any, any>> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
const requestId = uuidv4()
|
|
||||||
if(this.connectionStateSubject.value == true) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.hubConnection.invoke("ReadAt", { roomId: data.roomId, memberId: data.memberId, requestId, messageId: data.chatMessageId} as any)
|
|
||||||
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
this.readAtSubject.pipe(
|
|
||||||
filter((message: any) => {
|
|
||||||
return requestId == message?.requestId
|
|
||||||
}),
|
|
||||||
first()
|
|
||||||
).subscribe(value => {
|
|
||||||
resolve(ok(value));
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.sendLaterSubject.next({method: 'SendMessage', args: data})
|
|
||||||
return reject(err(false))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sendData<T>(input: ISignalRInput): Promise<Result<T, any>> {
|
sendData<T>(input: ISignalRInput): Promise<Result<T, any>> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
@@ -165,88 +131,26 @@ export class SignalRConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private addMessageListener(): void {
|
private addMessageListener(): void {
|
||||||
console.log('listening')
|
|
||||||
this.hubConnection.on('ReceiveMessage', (message: MessageOutPutDataDTO) => {
|
const methods = ['ReceiveMessage', 'TypingMessage', 'AvailableUsers',
|
||||||
console.log('ReceiveMessage', message)
|
'ReadAt', 'DeleteMessage', 'UpdateMessage', 'GroupAddedMembers',
|
||||||
this.messageSubject.next(message);
|
'GroupDeletedMembers']
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'ReceiveMessage',
|
|
||||||
data: message
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hubConnection.on('TypingMessage', (_typing: UserTypingDTO) => {
|
for(const method of methods) {
|
||||||
this.typingSubject.next(_typing);
|
this.hubConnection.on(method, (message: MessageOutPutDataDTO) => {
|
||||||
this.sendDataSubject.next({
|
this.messageSubject.next(message);
|
||||||
method: 'ReceiveMessage',
|
this.sendDataSubject.next({
|
||||||
data: _typing
|
method: method,
|
||||||
})
|
data: message
|
||||||
});
|
})
|
||||||
|
});
|
||||||
this.hubConnection.on('AvailableUsers', (data: any) => {
|
}
|
||||||
this.typingSubject.next(data);
|
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'AvailableUsers',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hubConnection.on('ReadAt', (_message) => {
|
|
||||||
console.log('ReadAt', _message)
|
|
||||||
this.readAtSubject.next(_message);
|
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'ReceiveMessage',
|
|
||||||
data: _message
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hubConnection.on('DeleteMessage', (_message) => {
|
|
||||||
console.log('DeleteMessage', _message)
|
|
||||||
this.messageDelete.next(_message);
|
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'DeleteMessage',
|
|
||||||
data: _message
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hubConnection.on('UpdateMessage', (_message) => {
|
|
||||||
console.log('UpdateMessage', _message)
|
|
||||||
this.messageUPdateSubject.next(_message);
|
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'ReceiveMessage',
|
|
||||||
data: _message
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
this.hubConnection.on('GroupAddedMembers', (_message) => {
|
|
||||||
console.log('GroupAddedMembers', _message)
|
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'GroupAddedMembers',
|
|
||||||
data: _message
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
this.hubConnection.on('GroupDeletedMembers', (_message) => {
|
|
||||||
console.log('GroupDeletedMembers', _message)
|
|
||||||
this.sendDataSubject.next({
|
|
||||||
method: 'GroupDeletedMembers',
|
|
||||||
data: _message
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
public getMessageUpdateSubject() {
|
|
||||||
return this.messageUPdateSubject.asObservable()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMessages() {
|
public getMessages() {
|
||||||
return this.messageSubject.asObservable()
|
return this.messageSubject.asObservable()
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTyping() {
|
|
||||||
return this.typingSubject.asObservable()
|
|
||||||
}
|
|
||||||
|
|
||||||
public getConnectionState(): Observable<boolean> {
|
public getConnectionState(): Observable<boolean> {
|
||||||
return this.connectionStateSubject.asObservable();
|
return this.connectionStateSubject.asObservable();
|
||||||
@@ -256,13 +160,7 @@ export class SignalRConnection {
|
|||||||
return this.disconnectSubject.asObservable();
|
return this.disconnectSubject.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSendLater() {
|
|
||||||
return this.sendLaterSubject.asObservable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getMessageDelete() {
|
|
||||||
return this.messageDelete.asObservable()
|
|
||||||
}
|
|
||||||
|
|
||||||
public getData() {
|
public getData() {
|
||||||
return this.sendDataSubject.asObservable()
|
return this.sendDataSubject.asObservable()
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "CommonJS"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./**/*.ts" // Include all TypeScript files in the current directory and subdirectories
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -56,6 +56,10 @@ const routes: Routes = [
|
|||||||
path: 'contacts',
|
path: 'contacts',
|
||||||
loadChildren: () => import('./component/contacts/contacts.module').then( m => m.ContactsPageModule)
|
loadChildren: () => import('./component/contacts/contacts.module').then( m => m.ContactsPageModule)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'view-onces',
|
||||||
|
loadChildren: () => import('./modal/view-onces/view-onces.module').then( m => m.ViewOncesPageModule)
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {MatMenuModule} from '@angular/material/menu';
|
|||||||
import { LettersAvatarModule } from "ngx-letters-avatar";
|
import { LettersAvatarModule } from "ngx-letters-avatar";
|
||||||
import { PipesModule } from 'src/app/pipes/pipes.module';
|
import { PipesModule } from 'src/app/pipes/pipes.module';
|
||||||
import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe';
|
import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe';
|
||||||
|
import { ScrollingModule } from '@angular/cdk/scrolling';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -26,6 +27,7 @@ import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe';
|
|||||||
MatMenuModule,
|
MatMenuModule,
|
||||||
LettersAvatarModule,
|
LettersAvatarModule,
|
||||||
PipesModule,
|
PipesModule,
|
||||||
|
ScrollingModule,
|
||||||
],
|
],
|
||||||
exports: [MessagesPage],
|
exports: [MessagesPage],
|
||||||
declarations: [MessagesPage]
|
declarations: [MessagesPage]
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
*ngFor="let message of messages1[roomId]; let messageIndex = index" class="messages-list-item-wrapper"
|
*ngFor="let message of messages1[roomId]; let messageIndex = index" class="messages-list-item-wrapper"
|
||||||
[ngClass]="{'my-message': message.sender.wxUserId === sessionStore.user.UserId, 'other-message': message.sender.wxUserId !== sessionStore.user.UserId}"
|
[ngClass]="{'my-message': message.sender.wxUserId === SessionStore.user.UserId, 'other-message': message.sender.wxUserId !== SessionStore.user.UserId}"
|
||||||
>
|
>
|
||||||
<div class="message-container">
|
<div class="message-container">
|
||||||
|
|
||||||
@@ -67,13 +67,28 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
|
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
|
||||||
|
|
||||||
<img
|
<img
|
||||||
*ngIf="attachment.oneShot != true"
|
*ngIf="message.oneShot != true"
|
||||||
[src]="attachment.safeFile"
|
[src]="attachment.safeFile"
|
||||||
(load)="onImageLoad(message, messageIndex)"
|
(load)="onImageLoad(message, messageIndex)"
|
||||||
(error)="onImageError()">
|
(error)="onImageError()"
|
||||||
|
>
|
||||||
|
|
||||||
|
<div *ngIf="SessionStore.user.UserId == message.sender.wxUserId">
|
||||||
|
Mandou uma mensagen com visualização única
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <div *ngIf="SessionStore.user.UserId != message.sender.wxUserId && message.oneShot == true"> -->
|
||||||
|
<div *ngIf="message.oneShot == true" class="cursor-pointer">
|
||||||
|
<div (click)="viewOnce($event, message, i)">
|
||||||
|
Abrir a visualização única
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Audio">
|
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Audio">
|
||||||
<audio [src]="attachment.safeFile|safehtml" preload="metadata" class="flex-grow-1" controls controlsList="nodownload noplaybackrate"></audio>
|
<audio [src]="attachment.safeFile|safehtml" preload="metadata" class="flex-grow-1" controls controlsList="nodownload noplaybackrate"></audio>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -487,3 +487,11 @@ ion-footer {
|
|||||||
.modal button {
|
.modal button {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.view-file {
|
||||||
|
span {}
|
||||||
|
|
||||||
|
img {}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -47,7 +47,8 @@ import { RoomType } from "src/app/module/chat/domain/entity/group";
|
|||||||
import { RoomTable } from 'src/app/module/chat/infra/database/dexie/schema/room';
|
import { RoomTable } from 'src/app/module/chat/infra/database/dexie/schema/room';
|
||||||
import { Logger } from 'src/app/services/logger/main/service';
|
import { Logger } from 'src/app/services/logger/main/service';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
|
import { AlertController } from '@ionic/angular';
|
||||||
|
import { ViewOncesImagePage, ViewOncesImagePageInput } from '../../modal/view-onces/view-onces.page';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-messages',
|
selector: 'app-messages',
|
||||||
@@ -99,7 +100,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
duration = 0;
|
duration = 0;
|
||||||
|
|
||||||
audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
|
audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
|
||||||
sessionStore = SessionStore
|
SessionStore = SessionStore
|
||||||
audioPlay: Howl = null;
|
audioPlay: Howl = null;
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
audioProgress = 0;
|
audioProgress = 0;
|
||||||
@@ -168,6 +169,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
private userTypingLocalRepository: UserTypingLocalRepository,
|
private userTypingLocalRepository: UserTypingLocalRepository,
|
||||||
private UserTypingRemoteRepositoryService: UserTypingRemoteRepositoryService,
|
private UserTypingRemoteRepositoryService: UserTypingRemoteRepositoryService,
|
||||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||||
|
private alertController: AlertController
|
||||||
) {
|
) {
|
||||||
// update
|
// update
|
||||||
this.checkAudioPermission()
|
this.checkAudioPermission()
|
||||||
@@ -279,6 +281,22 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
async onImageError() {}
|
async onImageError() {}
|
||||||
|
|
||||||
|
async viewOnce(event: Event, message: MessageEntity, index:number) {
|
||||||
|
const params: ViewOncesImagePageInput = {
|
||||||
|
imageDataUrl: message.attachments[index].safeFile as any,
|
||||||
|
}
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: ViewOncesImagePage,
|
||||||
|
cssClass: '',
|
||||||
|
componentProps: params
|
||||||
|
});
|
||||||
|
|
||||||
|
modal.present()
|
||||||
|
|
||||||
|
return modal.onDidDismiss().then((res) => {
|
||||||
|
this.messageDelete(message)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sendReadMessage() {
|
sendReadMessage() {
|
||||||
|
|
||||||
@@ -828,6 +846,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
async takePictureMobile() {
|
async takePictureMobile() {
|
||||||
|
|
||||||
|
const oneShot = await this.askIfOneShot()
|
||||||
|
|
||||||
const picture = await this.CameraService.takePicture({
|
const picture = await this.CameraService.takePicture({
|
||||||
cameraResultType: CameraResultType.DataUrl,
|
cameraResultType: CameraResultType.DataUrl,
|
||||||
quality: 90
|
quality: 90
|
||||||
@@ -847,6 +867,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
const message = new MessageEntity();
|
const message = new MessageEntity();
|
||||||
message.roomId = this.roomId
|
message.roomId = this.roomId
|
||||||
|
message.oneShot = oneShot
|
||||||
|
|
||||||
message.sender = {
|
message.sender = {
|
||||||
userPhoto: '',
|
userPhoto: '',
|
||||||
@@ -934,8 +955,43 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
await modal.present();
|
await modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
askIfOneShot(): Promise<boolean> {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
const alert = await this.alertController.create({
|
||||||
|
header: 'Confirm',
|
||||||
|
message: 'Visualização unica?',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: 'não',
|
||||||
|
role: 'cancel',
|
||||||
|
handler: () => {
|
||||||
|
resolve(false)
|
||||||
|
console.log('User clicked No');
|
||||||
|
// Handle No action here
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Sim',
|
||||||
|
handler: () => {
|
||||||
|
console.log('User clicked Yes');
|
||||||
|
resolve(true)
|
||||||
|
// Handle Yes action here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
await alert.present();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async pickPicture() {
|
async pickPicture() {
|
||||||
|
|
||||||
|
const oneShot = await this.askIfOneShot()
|
||||||
|
|
||||||
const file = await this.FilePickerService.getPicture({
|
const file = await this.FilePickerService.getPicture({
|
||||||
cameraResultType: CameraResultType.Base64
|
cameraResultType: CameraResultType.Base64
|
||||||
})
|
})
|
||||||
@@ -958,6 +1014,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
message.roomId = this.roomId
|
message.roomId = this.roomId
|
||||||
|
|
||||||
message.sentAt = new Date().toISOString()
|
message.sentAt = new Date().toISOString()
|
||||||
|
message.oneShot = oneShot
|
||||||
|
|
||||||
message.sender = {
|
message.sender = {
|
||||||
userPhoto: '',
|
userPhoto: '',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class SetRoomOwnerPage implements OnInit {
|
|||||||
textSearch:string = "";
|
textSearch:string = "";
|
||||||
roomId:any;
|
roomId:any;
|
||||||
members:any;
|
members:any;
|
||||||
roomMembers$: DexieObservable<MemberTable[] | undefined>
|
roomMembers$!: DexieObservable<MemberTable[] | undefined>
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
@@ -42,11 +42,11 @@ export class SetRoomOwnerPage implements OnInit {
|
|||||||
this.modalController.dismiss();
|
this.modalController.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(event) {
|
onChange(event: any) {
|
||||||
this.textSearch = event.detail.value;
|
this.textSearch = event.detail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
separateLetter(record:MemberTable, recordIndex, records:MemberTable[]) {
|
separateLetter(record:MemberTable, recordIndex: number, records:MemberTable[]) {
|
||||||
if(recordIndex == 0){
|
if(recordIndex == 0){
|
||||||
return record.wxFullName[0];
|
return record.wxFullName[0];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import { ViewOncesImagePage } from './view-onces.page';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: ViewOncesImagePage
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule],
|
||||||
|
})
|
||||||
|
export class ViewOncesPageRoutingModule {}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import { IonicModule } from '@ionic/angular';
|
||||||
|
|
||||||
|
import { ViewOncesPageRoutingModule } from './view-onces-routing.module';
|
||||||
|
|
||||||
|
import { ViewOncesImagePage } from './view-onces.page';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
FormsModule,
|
||||||
|
IonicModule,
|
||||||
|
ViewOncesPageRoutingModule
|
||||||
|
],
|
||||||
|
declarations: [ViewOncesImagePage]
|
||||||
|
})
|
||||||
|
export class ViewOncesPageModule {}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<ion-header>
|
||||||
|
<ion-toolbar class="d-flex justify-space-between">
|
||||||
|
<ion-title>Vizualização única</ion-title>
|
||||||
|
<ion-buttons slot="end">
|
||||||
|
<ion-button (click)="closePage()" fill="clear">
|
||||||
|
<ion-icon name="close"></ion-icon>
|
||||||
|
</ion-button>
|
||||||
|
</ion-buttons>
|
||||||
|
</ion-toolbar>
|
||||||
|
</ion-header>
|
||||||
|
|
||||||
|
<ion-content>
|
||||||
|
<div class="justify-center align-center d-flex width-100 height-100">
|
||||||
|
<img [src]="params.imageDataUrl">
|
||||||
|
</div>
|
||||||
|
</ion-content>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
import { IonicModule } from '@ionic/angular';
|
||||||
|
|
||||||
|
import { ViewOncesPage } from './view-onces.page';
|
||||||
|
|
||||||
|
describe('ViewOncesPage', () => {
|
||||||
|
let component: ViewOncesPage;
|
||||||
|
let fixture: ComponentFixture<ViewOncesPage>;
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ViewOncesPage ],
|
||||||
|
imports: [IonicModule.forRoot()]
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ViewOncesPage);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { NavParams, ModalController } from '@ionic/angular';
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
|
||||||
|
const ViewOncesImagePageInputSchema = z.object({
|
||||||
|
// messageId: z.string(),
|
||||||
|
// attachmentIndex: z.number(),
|
||||||
|
imageDataUrl: z.string()
|
||||||
|
})
|
||||||
|
|
||||||
|
export type ViewOncesImagePageInput = z.infer<typeof ViewOncesImagePageInputSchema>
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-view-onces',
|
||||||
|
templateUrl: './view-onces.page.html',
|
||||||
|
styleUrls: ['./view-onces.page.scss'],
|
||||||
|
})
|
||||||
|
export class ViewOncesImagePage implements OnInit {
|
||||||
|
|
||||||
|
params: ViewOncesImagePageInput
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private navParams: NavParams,
|
||||||
|
public modalController: ModalController,
|
||||||
|
) {
|
||||||
|
this.params = this.navParams.data
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
|
||||||
|
// console.log('niceddd')
|
||||||
|
// this.message = this.navParams.get('message');
|
||||||
|
// console.log('this.message', this.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
closePage() {
|
||||||
|
this.modalController.dismiss({})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,22 +3,22 @@ import { MessageAttachmentFileType, MessageAttachmentSource } from "src/app/modu
|
|||||||
import { MessageEntity } from "src/app/module/chat/domain/entity/message";
|
import { MessageEntity } from "src/app/module/chat/domain/entity/message";
|
||||||
|
|
||||||
export class MessageViewModal {
|
export class MessageViewModal {
|
||||||
$id: number
|
$id!: number
|
||||||
id: string
|
id!: string
|
||||||
roomId?: string
|
roomId?: string
|
||||||
receiverId?: number
|
receiverId?: number
|
||||||
message: string
|
message!: string
|
||||||
messageType: number = 0
|
messageType: number = 0
|
||||||
canEdit: boolean = false
|
canEdit: boolean = false
|
||||||
oneShot: boolean = false
|
oneShot: boolean = false
|
||||||
sentAt: string
|
sentAt!: string
|
||||||
requireUnlock: boolean = false
|
requireUnlock: boolean = false
|
||||||
info: {
|
info: {
|
||||||
memberId?: number
|
memberId?: number
|
||||||
readAt?: string,
|
readAt?: string,
|
||||||
deliverAt?: string
|
deliverAt?: string
|
||||||
}[] = []
|
}[] = []
|
||||||
sender: {
|
sender!: {
|
||||||
wxUserId: number,
|
wxUserId: number,
|
||||||
wxFullName: string,
|
wxFullName: string,
|
||||||
wxeMail: string,
|
wxeMail: string,
|
||||||
@@ -41,7 +41,7 @@ export class MessageViewModal {
|
|||||||
}[] = []
|
}[] = []
|
||||||
|
|
||||||
reactions = []
|
reactions = []
|
||||||
requestId: string
|
requestId!: string
|
||||||
status = ''
|
status = ''
|
||||||
|
|
||||||
constructor(model: MessageEntity) {
|
constructor(model: MessageEntity) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { err, ok } from 'neverthrow';
|
import { err, ok } from 'neverthrow';
|
||||||
import { ZodError, ZodSchema, z } from 'zod';
|
import { ZodError, ZodSchema, z } from 'zod';
|
||||||
export function zodSafeValidation<T>(schema: ZodSchema, data) {
|
export function zodSafeValidation<T>(schema: ZodSchema, data: unknown) {
|
||||||
const validation = (schema as ZodSchema<T>).safeParse(data)
|
const validation = (schema as ZodSchema<T>).safeParse(data)
|
||||||
|
|
||||||
if(validation.success) {
|
if(validation.success) {
|
||||||
|
|||||||
Reference in New Issue
Block a user