mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
create room
This commit is contained in:
@@ -96,7 +96,7 @@ import { DeplomaOptionsPageModule } from './shared/popover/deploma-options/deplo
|
||||
import { DiplomaOptionsPage } from './shared/popover/deploma-options/deploma-options.page';
|
||||
import { ImageCropperModule } from 'ngx-image-cropper';
|
||||
import { createAction, createReducer, on, StoreModule } from '@ngrx/store';
|
||||
import { chatReducer } from './services/Repositorys/chat/data-source/room-memory-data-source';
|
||||
import { chatReducer } from './services/Repositorys/chat/data-source/room/room-memory-data-source';
|
||||
// import { ServiceWorkerModule } from '@angular/service-worker';
|
||||
// import { AngularFireModule } from '@angular/fire';
|
||||
// import { AngularFireMessagingModule } from '@angular/fire/messaging';
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
</div>
|
||||
<div class="div-icon">
|
||||
|
||||
<!-- <button (click)="openChatDebuggingPageModal()" title="Nova Conversa Individual" class="btn-no-color font-12">
|
||||
Dev
|
||||
</button> -->
|
||||
<button title="Nova Conversa Individual" class="btn-no-color" (click)="openContactsPage()">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src="assets/images/icons-chat-new-conversation.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src="assets/images/theme/gov/icons-chat-new-conversation.svg"></ion-icon>
|
||||
@@ -31,21 +28,88 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Current Count Object: {{ count$ | async | json }}</h3>
|
||||
<ion-toolbar [class.block-button]="showNewEvent || showNewGroup || showContacts">
|
||||
<ion-segment [(ngModel)]="segment" (ionChange)="onSegmentChange()">
|
||||
<ion-segment-button value="Contactos" class="font-14-em">
|
||||
Conversas
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="Grupos" class="font-14-em">
|
||||
Grupos
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
|
||||
<div *ngFor="let item of (count$ | async)?.chatRooms | keyvalue">
|
||||
<p>{{ item.key }}: {{ item.value | json }}</p>
|
||||
</div>
|
||||
<!-- <p>Current Count: {{ (count$ | async)?.count }}</p> -->
|
||||
<!-- <p>Current Count Details: {{ (count$ | async)?.details }}</p> -->
|
||||
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
|
||||
<div class="width-100" [ngSwitch]="segment">
|
||||
<ion-list *ngSwitchCase="'Contactos'">
|
||||
<ion-item-sliding>
|
||||
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
|
||||
*ngFor="let room of (items$ | async)"
|
||||
[class.item-active]="room.id == idSelected">
|
||||
<div class="item-icon">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40-hover.svg"></ion-icon>
|
||||
</div>
|
||||
<div
|
||||
(click)="openMessagesPage(room.id)"
|
||||
class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
|
||||
<div class="item-title-time">
|
||||
<div class="item-title" [class.item-title-active]="room.id == idSelected">
|
||||
<ion-label >
|
||||
<span >
|
||||
<div >
|
||||
<div class="font-15-em" [class.bold-message]="true">
|
||||
{{room.roomName}}
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
<!-- <div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">{{room.duration}}</div> -->
|
||||
</div>
|
||||
<!-- <div *ngIf="room.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
|
||||
<div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="room.otherUserType == false"> {{room.lastMessage.msg}} </div>
|
||||
<div class="font-13-em" *ngIf="room.otherUserType == true">está escrever ...</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</ion-item-sliding>
|
||||
</ion-list>
|
||||
<ion-list *ngSwitchCase="'Grupos'">
|
||||
<ion-item-sliding >
|
||||
<div *ngFor="let group of ChatSystemService._group"
|
||||
|
||||
[class.item-active]="group.id ==idSelected"
|
||||
class="item item-hover d-flex">
|
||||
|
||||
<div class="item-icon">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && group.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && group.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40-hover.svg"></ion-icon>
|
||||
</div>
|
||||
<div (click)="openGroupMessagesPage(group.id)" class="item-content flex-grow-1 cursor-pointer">
|
||||
<div class="item-title-time">
|
||||
<div class="item-title add-ellipsis" [class.item-title-active]="group.id ==idSelected">
|
||||
<p class="font-15-em add-ellipsis mb-0 white-space-nowrap" [class.bold-message]="group.messageUnread == true">{{group.name.split('-').join(' ')}}</p>
|
||||
</div>
|
||||
<div class="item-date font-13-em" [class.item-date-active]="group.id ==idSelected" *ngIf="group.lastMessage && !group.customFields.countDownDate">{{group.duration }}</div>
|
||||
<div class="item-date font-13-em" [class.item-date-active]="group.id ==idSelected" *ngIf="group.customFields.countDownDate">{{group.countDownTime }}</div>
|
||||
</div>
|
||||
<div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.id ==idSelected">
|
||||
<div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="group.otherUserType == false">{{group.lastMessage.u.name}} <span *ngIf="group.lastMessage.u.name">:</span> {{group.lastMessage.msg}} </div>
|
||||
<div class="font-13-em" *ngIf="group.otherUserType == true">{{group.userThatIsTyping}} está escrever ...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ion-item-sliding>
|
||||
</ion-list>
|
||||
</div>
|
||||
|
||||
<!-- <button (click)="sendMsg()" style="height: 41px;">Send message</button> -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- Aside right -->
|
||||
<div class="aside-content d-none flex-column height-100">
|
||||
|
||||
<div>Current Count: {{ count$ | async }}</div>
|
||||
|
||||
|
||||
<app-empty-chat [texto]="emptyTextDescription"
|
||||
class="height-100 flex-column"
|
||||
[style.display]="showEmptyComponent && !showContacts && !showNewGroup && !showEditGroup && !showGroupContacts && !showGroupMessages && !showNewEvent ? 'flex' : 'none'"
|
||||
@@ -76,17 +140,6 @@
|
||||
class=" height-100 flex-column">
|
||||
</app-contacts>
|
||||
|
||||
<!-- <app-contacts
|
||||
(openMessage)="openMessagesPage($event)"
|
||||
(backToChat)="backToChat($event)"
|
||||
(emptyTextDescriptionOpen)="emptyTextDescriptionOpen()"
|
||||
(closeAllDesktopComponents)="closeAllDesktopComponents()"
|
||||
*ngIf="showContacts"
|
||||
[roomId]="roomId"
|
||||
[style.display]="showContacts ? 'flex' : 'none'"
|
||||
class=" height-100 flex-column">
|
||||
</app-contacts> -->
|
||||
|
||||
<app-new-group
|
||||
(addGroupMessage)="openGroupContactsPage($event)"
|
||||
[roomId]="roomId"
|
||||
|
||||
@@ -33,8 +33,9 @@ import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-co
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { RoomRemoteDataSourceState } from 'src/app/services/Repositorys/chat/data-source/room-memory-data-source';
|
||||
|
||||
import { RoomRemoteDataSourceState } from 'src/app/services/Repositorys/chat/data-source/room/room-memory-data-source';
|
||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service'
|
||||
import { RoomListOutPutDTO } from 'src/app/services/Repositorys/chat/dto/room/roomListOutputDTO';
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
@@ -114,6 +115,7 @@ export class ChatPage implements OnInit {
|
||||
routerSubscription
|
||||
|
||||
count$: Observable<RoomRemoteDataSourceState>;
|
||||
items$!: Observable<RoomListOutPutDTO[]>;
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -134,12 +136,13 @@ export class ChatPage implements OnInit {
|
||||
private RochetChatConnectorService: RochetChatConnectorService,
|
||||
private zone: NgZone,
|
||||
public RouteService: RouteService,
|
||||
private store: Store<{ chat: RoomRemoteDataSourceState }>
|
||||
private store: Store<{ chat: RoomRemoteDataSourceState }>,
|
||||
private RoomRepositoryService: RoomRepositoryService
|
||||
) {
|
||||
|
||||
this.count$ = store.select('chat');
|
||||
|
||||
this.headers = new HttpHeaders();;
|
||||
this.headers = new HttpHeaders();
|
||||
window.onresize = (event) => {
|
||||
if (window.innerWidth > 701) {
|
||||
this.modalController.dismiss();
|
||||
@@ -159,8 +162,12 @@ export class ChatPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
// Fetch all items using useLiveQuery
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.items$ = this.RoomRepositoryService.getItemsLive()
|
||||
|
||||
this.segment = "Contactos";
|
||||
|
||||
this.authService.userData$.subscribe((res: any) => {
|
||||
|
||||
@@ -71,7 +71,6 @@ export class EventsPage implements OnInit {
|
||||
|
||||
agendaColor = ''
|
||||
|
||||
|
||||
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Não lidos'
|
||||
showSearch = true;
|
||||
searchSubject: string = '';
|
||||
@@ -81,7 +80,6 @@ export class EventsPage implements OnInit {
|
||||
delete(): void;
|
||||
}
|
||||
|
||||
|
||||
count$: Observable<number>;
|
||||
|
||||
constructor(
|
||||
|
||||
+3
-3
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { MessageOutPutDTO } from '../../dto/message/messageOutputDTO';
|
||||
import { MessageListInputDTO } from '../../dto/message/messageListInputDTO';
|
||||
import { DataSourceReturn } from '../../../type';
|
||||
|
||||
|
||||
@Injectable({
|
||||
@@ -13,7 +14,6 @@ export class MessageRemoteDataSourceService {
|
||||
|
||||
constructor(private httpService: HttpService) {}
|
||||
|
||||
|
||||
async sendMessage(message: any) {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Messages`, message);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export class MessageRemoteDataSourceService {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
|
||||
}
|
||||
|
||||
async getMessagesFromRoom(id: MessageListInputDTO) {
|
||||
return await this.httpService.get<MessageOutPutDTO>(`${this.baseUrl}/Room/${id}/Messages`);
|
||||
async getMessagesFromRoom(id: MessageListInputDTO): DataSourceReturn<MessageListInputDTO> {
|
||||
return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-18
@@ -1,10 +1,12 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ok, err, Result } from 'neverthrow';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { RoomListOutPutDTO } from '../dto/roomListOutputDTO';
|
||||
import { RoomListInputDTO } from '../dto/roomInputDTO';
|
||||
import { RoomOutPutDTO } from '../dto/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO } from '../dto/addMemberToRoomInputDto';
|
||||
import { RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
|
||||
import { RoomInputDTO, RoomInputDTOSchema } from '../../dto/room/roomInputDTO';
|
||||
import { RoomOutPutDTO } from '../../dto/room/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../../dto/room/addMemberToRoomInputDto';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { DataSourceReturn } from '../../../type';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -15,16 +17,10 @@ export class RoomRemoteDataSourceService {
|
||||
|
||||
constructor(private httpService: HttpService) {}
|
||||
|
||||
async sendMessage(message: any): Promise<Result<any ,any>> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Messages`, message);
|
||||
}
|
||||
|
||||
async reactToMessage(id: string, reaction: any): Promise<Result<any ,any>> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
|
||||
}
|
||||
|
||||
async createRoom(data: RoomListInputDTO): Promise<Result<RoomOutPutDTO ,any>> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Room`, data);
|
||||
@ValidateSchema(RoomInputDTOSchema)
|
||||
async createRoom(data: RoomInputDTO): DataSourceReturn<RoomOutPutDTO> {
|
||||
return await this.httpService.post<RoomOutPutDTO>(`${this.baseUrl}/Room`, data);
|
||||
}
|
||||
|
||||
async getRoomList(): Promise<Result<RoomListOutPutDTO ,any>> {
|
||||
@@ -43,7 +39,8 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO) {
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO): DataSourceReturn<AddMemberToRoomInputDTO> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Room/${data.id}/Member`, data.member);
|
||||
}
|
||||
|
||||
@@ -51,7 +48,4 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${id}/Member`);
|
||||
}
|
||||
|
||||
async getMessagesFromRoom(id: string): Promise<Result<any ,any>> {
|
||||
return await this.httpService.get<any>(`${this.baseUrl}/Room/${id}/Messages`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AddMemberToRoomInputDTO } from '../../dto/room/addMemberToRoomInputDto';
|
||||
import { RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
|
||||
import { Dexie, EntityTable, liveQuery } from 'Dexie';
|
||||
import { err, ok } from 'neverthrow';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RoomOutPutDTO } from '../../dto/room/roomOutputDTO';
|
||||
import { z } from 'zod';
|
||||
|
||||
|
||||
|
||||
const tableSchema = z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: z.any(),
|
||||
createdAt: z.any(),
|
||||
expirationDate: z.any(),
|
||||
roomType: z.any()
|
||||
})
|
||||
export type Table = z.infer<typeof tableSchema>
|
||||
|
||||
// Database declaration (move this to its own module also)
|
||||
export const roomDataSource = new Dexie('FriendDatabase') as Dexie & {
|
||||
room: EntityTable<Table, 'id'>;
|
||||
};
|
||||
|
||||
roomDataSource.version(1).stores({
|
||||
room: '++id, createdBy, roomName, roomType, expirationDate'
|
||||
});
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RoomLocalDataSourceService {
|
||||
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
||||
|
||||
constructor() {}
|
||||
|
||||
|
||||
async createRoom(data: RoomOutPutDTO) {
|
||||
|
||||
const roomData = {
|
||||
createdBy: {
|
||||
wxUserId: 0,
|
||||
wxFullName: "",
|
||||
wxeMail: "",
|
||||
userPhoto: ""
|
||||
},
|
||||
roomName: data.data.roomName,
|
||||
id: data.data.id,
|
||||
roomType: 21,
|
||||
expirationDate: '',
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await roomDataSource.room.add(roomData)
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
return err(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async getRoomList() {
|
||||
|
||||
}
|
||||
|
||||
async getRoom(id: string){
|
||||
|
||||
}
|
||||
|
||||
async updateRoom(id: string, room: any) {
|
||||
|
||||
}
|
||||
|
||||
async deleteRoom(id: string){
|
||||
|
||||
}
|
||||
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO) {
|
||||
|
||||
}
|
||||
|
||||
async removeMemberFromRoom(id: string, member: any){
|
||||
|
||||
}
|
||||
|
||||
getItemsLive(): Observable<RoomListOutPutDTO[]> {
|
||||
return liveQuery(() => roomDataSource.room.toArray()) as any;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { z } from "zod"
|
||||
|
||||
const MessageListInputDTOSchema = z.object({
|
||||
roomId: z.string(),
|
||||
});
|
||||
|
||||
export type MessageListInputDTO = z.infer<typeof MessageListInputDTOSchema>
|
||||
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod"
|
||||
|
||||
const MessageOutPutDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
sender: z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string().email(),
|
||||
userPhoto: z.string()
|
||||
}),
|
||||
message: z.string().datetime(),
|
||||
messageType: z.string().datetime(),
|
||||
sentAt: z.number(),
|
||||
deliverAt: z.any(),
|
||||
canEdit: z.any(),
|
||||
oneShot: z.any(),
|
||||
requireUnlock: z.any()
|
||||
});
|
||||
|
||||
export type MessageOutPutDTO = z.infer<typeof MessageOutPutDTOSchema>
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomListInputDTOSchema = z.object({
|
||||
export const RoomInputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
createdBy: z.number(),
|
||||
roomType: z.number(),
|
||||
@@ -8,4 +8,4 @@ export const RoomListInputDTOSchema = z.object({
|
||||
});
|
||||
|
||||
|
||||
export type RoomListInputDTO = z.infer<typeof RoomListInputDTOSchema>
|
||||
export type RoomInputDTO = z.infer<typeof RoomInputDTOSchema>
|
||||
+3
-2
@@ -7,7 +7,7 @@ const CreatedBySchema = z.object({
|
||||
userPhoto: z.string()
|
||||
});
|
||||
|
||||
const RoomListOutPutDTOSchema = z.object({
|
||||
const RoomListItemOutPutDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: CreatedBySchema,
|
||||
@@ -15,7 +15,8 @@ const RoomListOutPutDTOSchema = z.object({
|
||||
expirationDate: z.string().datetime(),
|
||||
roomType: z.number()
|
||||
});
|
||||
export type RoomListItemOutPutDTO = z.infer<typeof RoomListItemOutPutDTOSchema>
|
||||
|
||||
|
||||
|
||||
const RoomListOutPutDTOSchema = z.array(RoomListItemOutPutDTOSchema);
|
||||
export type RoomListOutPutDTO = z.infer<typeof RoomListOutPutDTOSchema>
|
||||
+8
-1
@@ -3,7 +3,14 @@ import { z } from "zod";
|
||||
const RoomOutPutDTOSchema = z.object({
|
||||
success: z.string(),
|
||||
message: z.string(),
|
||||
data: z.any()
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: z.any(),
|
||||
createdAt: z.date(),
|
||||
expirationDate: z.date(),
|
||||
roomType: z.any()
|
||||
})
|
||||
});
|
||||
|
||||
export type RoomOutPutDTO = z.infer<typeof RoomOutPutDTOSchema>
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageRemoteDataSourceService } from '../data-source/message/message-remote-data-source.service';
|
||||
import { MessageLiveDataSourceService } from '../data-source/message/message-live-data-source.service';
|
||||
import { MessageListInputDTO } from '../dto/message/messageListInputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -6,5 +9,17 @@ import { Injectable } from '@angular/core';
|
||||
export class MessageRepositoryService {
|
||||
|
||||
constructor(
|
||||
) { }
|
||||
private messageRemoteDataSourceService: MessageRemoteDataSourceService,
|
||||
private messageLiveDataSourceService: MessageLiveDataSourceService
|
||||
) {}
|
||||
|
||||
async sendMessage() {
|
||||
// const result = this.messageRemoteDataSourceService.sendMessage()
|
||||
}
|
||||
|
||||
async getMessagesFromRoom(data: MessageListInputDTO) {
|
||||
const result = await this.messageRemoteDataSourceService.getMessagesFromRoom(data)
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RoomRemoteDataSourceService } from '../data-source/room-remote-data-source.service'
|
||||
import { RoomListInputDTO, RoomListInputDTOSchema } from '../dto/roomInputDTO';
|
||||
import { IRepositoryReturn } from '../../type';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { addRoom, RoomRemoteDataSourceState } from '../data-source/room-memory-data-source';
|
||||
import { RoomRemoteDataSourceService } from '../data-source/room/room-remote-data-source.service'
|
||||
import { RoomInputDTO } from '../dto/room/roomInputDTO';;
|
||||
import { addRoom, RoomRemoteDataSourceState } from '../data-source/room/room-memory-data-source';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../dto/addMemberToRoomInputDto';
|
||||
import { RoomOutPutDTO } from '../dto/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO } from '../dto/room/addMemberToRoomInputDto';
|
||||
import { RoomLocalDataSourceService } from '../data-source/room/rooom-local-data-source.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -15,15 +13,19 @@ export class RoomRepositoryService {
|
||||
|
||||
constructor(
|
||||
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
||||
private roomMemoryDataSourceService: Store<RoomRemoteDataSourceState>
|
||||
private roomMemoryDataSourceService: Store<RoomRemoteDataSourceState>,
|
||||
private roomLocalDataSourceService: RoomLocalDataSourceService
|
||||
) { }
|
||||
|
||||
list() {
|
||||
this.roomRemoteDataSourceService.getRoomList()
|
||||
async list() {
|
||||
const result = await this.roomRemoteDataSourceService.getRoomList()
|
||||
return result
|
||||
}
|
||||
|
||||
@ValidateSchema(RoomListInputDTOSchema)
|
||||
async create(data: RoomListInputDTO): IRepositoryReturn<RoomOutPutDTO> {
|
||||
async create(data: RoomInputDTO) {
|
||||
|
||||
this.list()
|
||||
|
||||
const result = await this.roomRemoteDataSourceService.createRoom(data)
|
||||
|
||||
if(result.isOk()) {
|
||||
@@ -32,15 +34,21 @@ export class RoomRepositoryService {
|
||||
timestamp: 0,
|
||||
roomName: data.roomName
|
||||
}))
|
||||
|
||||
this.roomLocalDataSourceService.createRoom(result.value)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO): IRepositoryReturn<AddMemberToRoomInputDTO> {
|
||||
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO) {
|
||||
const result = await this.roomRemoteDataSourceService.addMemberToRoom(data)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
getItemsLive() {
|
||||
return this.roomLocalDataSourceService.getItemsLive()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserRepositoryService {
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
@@ -2,4 +2,4 @@ import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { Result } from "neverthrow";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
export type IRepositoryReturn<T> = Promise<Result<any, HttpErrorResponse | ZodError>>
|
||||
export type DataSourceReturn<T> = Promise<Result<T, HttpErrorResponse | ZodError>>
|
||||
|
||||
@@ -173,7 +173,7 @@ export class NewGroupPage implements OnInit{
|
||||
async createGroup1() {
|
||||
const result = await this.roomRepositoryService.create({
|
||||
roomName: this.groupName,
|
||||
createdBy: 0,
|
||||
createdBy: SessionStore.user.UserId,
|
||||
roomType: 0,
|
||||
expirationDate: null
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user