mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
direct message
This commit is contained in:
@@ -21,7 +21,7 @@ export class RoomSocketRepositoryService {
|
||||
|
||||
listenToCreateRoom() {
|
||||
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>;
|
||||
|
||||
export class MessageEntity implements Message {
|
||||
export class MessageEntity {
|
||||
|
||||
$id: number
|
||||
id: string
|
||||
$id?: number
|
||||
id?: string
|
||||
roomId?: string
|
||||
receiverId?: number
|
||||
message: string
|
||||
message?: string
|
||||
messageType: number = 0
|
||||
canEdit: boolean = false
|
||||
oneShot: boolean = false
|
||||
sentAt: string
|
||||
sentAt?: string
|
||||
requireUnlock: boolean = false
|
||||
info: {
|
||||
memberId?: number
|
||||
readAt?: string,
|
||||
deliverAt?: string
|
||||
}[] = []
|
||||
sender: {
|
||||
sender!: {
|
||||
wxUserId: number,
|
||||
wxFullName: string,
|
||||
wxeMail: string,
|
||||
@@ -82,7 +82,7 @@ export class MessageEntity implements Message {
|
||||
|
||||
reactions = []
|
||||
|
||||
requestId: string
|
||||
requestId!: string
|
||||
|
||||
constructor() {}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { err, ok } from 'neverthrow';
|
||||
import { SessionStore } from 'src/app/store/session.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 { SignalRService } from '../../infra/socket/signal-r.service';
|
||||
|
||||
@@ -11,7 +12,7 @@ import { SignalRService } from '../../infra/socket/signal-r.service';
|
||||
export class MessageReadAtByIdUseCaseService {
|
||||
|
||||
constructor(
|
||||
private messageRemoteDataSourceService: MessageRemoteDataSourceService,
|
||||
private MessageSocketRepositoryService: MessageSocketRepositoryService,
|
||||
private messageLiveSignalRDataSourceService: SignalRService,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||
) { }
|
||||
@@ -21,7 +22,7 @@ export class MessageReadAtByIdUseCaseService {
|
||||
if(result.isOk()) {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -12,5 +12,8 @@ export class SocketJoinUseCaseService {
|
||||
) { }
|
||||
|
||||
|
||||
execute() {}
|
||||
execute() {
|
||||
|
||||
this.MessageSocketRepositoryService.sendDirectMessage
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, Subject, timer } from 'rxjs';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SignalRConnection } from './signalR';
|
||||
import { SignalRConnection, SocketMessage } from './signalR';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
import { UserTypingDTO } from '../../data/dto/typing/typingInputDTO';
|
||||
import { MessageOutPutDataDTO } from '../../data/dto/message/messageOutputDTO';
|
||||
import { MessageDeleteInputDTO } from '../../data/dto/message/messageDeleteInputDTO';
|
||||
import { z } from 'zod';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { filter, map, switchMap } from 'rxjs/operators';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HubConnection } from '@microsoft/signalr';
|
||||
|
||||
@@ -28,11 +28,7 @@ export type ISignalRInput = z.infer<typeof SignalRInputSchema>;
|
||||
})
|
||||
export class SignalRService {
|
||||
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 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 deadConnectionBackGround: Subject<any>;
|
||||
@@ -80,24 +76,6 @@ export class SignalRService {
|
||||
this.connection?.closeConnection()
|
||||
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.sendDataSubject.next(data)
|
||||
@@ -123,20 +101,36 @@ export class SignalRService {
|
||||
|
||||
|
||||
getMessage() {
|
||||
return this.messageSubject.asObservable()
|
||||
return this.getData().pipe(
|
||||
filter((e) : e is SocketMessage<MessageOutPutDataDTO>=> e?.method == 'ReceiveMessage'
|
||||
),
|
||||
map((e)=> e.data)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
getTyping() {
|
||||
return this.typingSubject.asObservable().pipe()
|
||||
return this.getData().pipe(
|
||||
filter((e) : e is SocketMessage<UserTypingDTO>=> e?.method == 'TypingMessage'
|
||||
),
|
||||
map((e)=> e.data)
|
||||
)
|
||||
}
|
||||
|
||||
getMessageDelete() {
|
||||
return this.messageDelete.asObservable()
|
||||
return this.getData().pipe(
|
||||
filter((e) : e is SocketMessage<MessageOutPutDataDTO>=> e?.method == 'DeleteMessage'
|
||||
),
|
||||
map((e)=> e.data)
|
||||
)
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -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 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 disconnectSubject: 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>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -165,88 +131,26 @@ export class SignalRConnection {
|
||||
}
|
||||
|
||||
private addMessageListener(): void {
|
||||
console.log('listening')
|
||||
this.hubConnection.on('ReceiveMessage', (message: MessageOutPutDataDTO) => {
|
||||
console.log('ReceiveMessage', message)
|
||||
this.messageSubject.next(message);
|
||||
this.sendDataSubject.next({
|
||||
method: 'ReceiveMessage',
|
||||
data: message
|
||||
})
|
||||
});
|
||||
|
||||
const methods = ['ReceiveMessage', 'TypingMessage', 'AvailableUsers',
|
||||
'ReadAt', 'DeleteMessage', 'UpdateMessage', 'GroupAddedMembers',
|
||||
'GroupDeletedMembers']
|
||||
|
||||
this.hubConnection.on('TypingMessage', (_typing: UserTypingDTO) => {
|
||||
this.typingSubject.next(_typing);
|
||||
this.sendDataSubject.next({
|
||||
method: 'ReceiveMessage',
|
||||
data: _typing
|
||||
})
|
||||
});
|
||||
|
||||
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()
|
||||
for(const method of methods) {
|
||||
this.hubConnection.on(method, (message: MessageOutPutDataDTO) => {
|
||||
this.messageSubject.next(message);
|
||||
this.sendDataSubject.next({
|
||||
method: method,
|
||||
data: message
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public getMessages() {
|
||||
return this.messageSubject.asObservable()
|
||||
}
|
||||
|
||||
public getTyping() {
|
||||
return this.typingSubject.asObservable()
|
||||
}
|
||||
|
||||
public getConnectionState(): Observable<boolean> {
|
||||
return this.connectionStateSubject.asObservable();
|
||||
@@ -256,13 +160,7 @@ export class SignalRConnection {
|
||||
return this.disconnectSubject.asObservable();
|
||||
}
|
||||
|
||||
public getSendLater() {
|
||||
return this.sendLaterSubject.asObservable();
|
||||
}
|
||||
|
||||
public getMessageDelete() {
|
||||
return this.messageDelete.asObservable()
|
||||
}
|
||||
|
||||
public getData() {
|
||||
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',
|
||||
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({
|
||||
|
||||
@@ -14,6 +14,7 @@ import {MatMenuModule} from '@angular/material/menu';
|
||||
import { LettersAvatarModule } from "ngx-letters-avatar";
|
||||
import { PipesModule } from 'src/app/pipes/pipes.module';
|
||||
import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe';
|
||||
import { ScrollingModule } from '@angular/cdk/scrolling';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -26,6 +27,7 @@ import { SafehtmlPipe } from 'src/app/pipes/safehtml.pipe';
|
||||
MatMenuModule,
|
||||
LettersAvatarModule,
|
||||
PipesModule,
|
||||
ScrollingModule,
|
||||
],
|
||||
exports: [MessagesPage],
|
||||
declarations: [MessagesPage]
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
<div
|
||||
*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">
|
||||
|
||||
@@ -67,13 +67,28 @@
|
||||
</div>
|
||||
|
||||
<div *ngIf="attachment.fileType == MessageAttachmentFileType.Image">
|
||||
|
||||
<img
|
||||
*ngIf="attachment.oneShot != true"
|
||||
*ngIf="message.oneShot != true"
|
||||
[src]="attachment.safeFile"
|
||||
(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 *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">
|
||||
<audio [src]="attachment.safeFile|safehtml" preload="metadata" class="flex-grow-1" controls controlsList="nodownload noplaybackrate"></audio>
|
||||
</div>
|
||||
|
||||
@@ -487,3 +487,11 @@ ion-footer {
|
||||
.modal button {
|
||||
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 { Logger } from 'src/app/services/logger/main/service';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { ViewOncesImagePage, ViewOncesImagePageInput } from '../../modal/view-onces/view-onces.page';
|
||||
|
||||
@Component({
|
||||
selector: 'app-messages',
|
||||
@@ -99,7 +100,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
duration = 0;
|
||||
|
||||
audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
|
||||
sessionStore = SessionStore
|
||||
SessionStore = SessionStore
|
||||
audioPlay: Howl = null;
|
||||
isPlaying = false;
|
||||
audioProgress = 0;
|
||||
@@ -168,6 +169,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private userTypingLocalRepository: UserTypingLocalRepository,
|
||||
private UserTypingRemoteRepositoryService: UserTypingRemoteRepositoryService,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||
private alertController: AlertController
|
||||
) {
|
||||
// update
|
||||
this.checkAudioPermission()
|
||||
@@ -279,6 +281,22 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
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() {
|
||||
|
||||
@@ -828,6 +846,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
async takePictureMobile() {
|
||||
|
||||
const oneShot = await this.askIfOneShot()
|
||||
|
||||
const picture = await this.CameraService.takePicture({
|
||||
cameraResultType: CameraResultType.DataUrl,
|
||||
quality: 90
|
||||
@@ -847,6 +867,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
|
||||
const message = new MessageEntity();
|
||||
message.roomId = this.roomId
|
||||
message.oneShot = oneShot
|
||||
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
@@ -934,8 +955,43 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
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() {
|
||||
|
||||
const oneShot = await this.askIfOneShot()
|
||||
|
||||
const file = await this.FilePickerService.getPicture({
|
||||
cameraResultType: CameraResultType.Base64
|
||||
})
|
||||
@@ -958,6 +1014,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
message.roomId = this.roomId
|
||||
|
||||
message.sentAt = new Date().toISOString()
|
||||
message.oneShot = oneShot
|
||||
|
||||
message.sender = {
|
||||
userPhoto: '',
|
||||
|
||||
@@ -19,7 +19,7 @@ export class SetRoomOwnerPage implements OnInit {
|
||||
textSearch:string = "";
|
||||
roomId:any;
|
||||
members:any;
|
||||
roomMembers$: DexieObservable<MemberTable[] | undefined>
|
||||
roomMembers$!: DexieObservable<MemberTable[] | undefined>
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
@@ -42,11 +42,11 @@ export class SetRoomOwnerPage implements OnInit {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
onChange(event) {
|
||||
onChange(event: any) {
|
||||
this.textSearch = event.detail.value;
|
||||
}
|
||||
|
||||
separateLetter(record:MemberTable, recordIndex, records:MemberTable[]) {
|
||||
separateLetter(record:MemberTable, recordIndex: number, records:MemberTable[]) {
|
||||
if(recordIndex == 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";
|
||||
|
||||
export class MessageViewModal {
|
||||
$id: number
|
||||
id: string
|
||||
$id!: number
|
||||
id!: string
|
||||
roomId?: string
|
||||
receiverId?: number
|
||||
message: string
|
||||
message!: string
|
||||
messageType: number = 0
|
||||
canEdit: boolean = false
|
||||
oneShot: boolean = false
|
||||
sentAt: string
|
||||
sentAt!: string
|
||||
requireUnlock: boolean = false
|
||||
info: {
|
||||
memberId?: number
|
||||
readAt?: string,
|
||||
deliverAt?: string
|
||||
}[] = []
|
||||
sender: {
|
||||
sender!: {
|
||||
wxUserId: number,
|
||||
wxFullName: string,
|
||||
wxeMail: string,
|
||||
@@ -41,7 +41,7 @@ export class MessageViewModal {
|
||||
}[] = []
|
||||
|
||||
reactions = []
|
||||
requestId: string
|
||||
requestId!: string
|
||||
status = ''
|
||||
|
||||
constructor(model: MessageEntity) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { err, ok } from 'neverthrow';
|
||||
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)
|
||||
|
||||
if(validation.success) {
|
||||
|
||||
Reference in New Issue
Block a user