mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix chat ui details
This commit is contained in:
@@ -37,6 +37,10 @@ import { DistributionService } from './domain/service/distribution.service'
|
||||
import { BoldLocalRepository } from './data/repository/bold/bold-local-repository';
|
||||
import { IBoldLocalRepository } from 'src/app/core/chat/repository/bold/bold-local-repository';
|
||||
import { RoomLastMessageService } from 'src/app/module/chat/domain/service/room-last-message.service'
|
||||
import { IUserPhotoLocalRepository } from 'src/app/core/chat/repository/user-photo/user-photo-local-repository';
|
||||
import { UserPhotoLocalRepository } from './data/repository/user-foto/user-photo-local-repository.service';
|
||||
import { IUserPhotoRemoteRepository } from 'src/app/core/chat/repository/user-photo/user-photo-remote-repository';
|
||||
import { UserPhotoRemoteRepositoryService } from './data/repository/user-foto/user-photo-remote-repository.service';
|
||||
@NgModule({
|
||||
imports: [HttpModule],
|
||||
providers: [
|
||||
@@ -100,6 +104,16 @@ import { RoomLastMessageService } from 'src/app/module/chat/domain/service/room-
|
||||
{
|
||||
provide: IBoldLocalRepository,
|
||||
useClass: BoldLocalRepository
|
||||
},
|
||||
// user-photo
|
||||
{
|
||||
provide: IUserPhotoLocalRepository,
|
||||
useClass: UserPhotoLocalRepository
|
||||
},
|
||||
//
|
||||
{
|
||||
provide: IUserPhotoRemoteRepository,
|
||||
useClass: UserPhotoRemoteRepositoryService
|
||||
}
|
||||
],
|
||||
declarations: [],
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import Dexie, { PromiseExtended } from 'Dexie';
|
||||
import { IUserPhotoLocalRepository } from 'src/app/core/chat/repository/user-photo/user-photo-local-repository';
|
||||
import { UserPhotoTable, UserPhotoTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/user-foto';
|
||||
import { chatDatabase } from 'src/app/infra/database/dexie/service';
|
||||
import { DexieRepository } from 'src/app/infra/repository/dexie/dexie-repository.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserPhotoLocalRepository extends DexieRepository<UserPhotoTable, UserPhotoTable> implements IUserPhotoLocalRepository {
|
||||
constructor() {
|
||||
super(chatDatabase.userPhoto, UserPhotoTableSchema)
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserPhotoRemoteRepositoryService } from './user-photo-remote-repository.service';
|
||||
|
||||
describe('UserPhotoRemoteRepositoryService', () => {
|
||||
let service: UserPhotoRemoteRepositoryService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UserPhotoRemoteRepositoryService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+17
-8
@@ -1,15 +1,24 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import Dexie, { PromiseExtended } from 'Dexie';
|
||||
import { IUserPhotoLocalRepository } from 'src/app/core/chat/repository/user-photo/user-photo-local-repository';
|
||||
import { UserPhotoTable, UserPhotoTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/user-foto';
|
||||
import { chatDatabase } from 'src/app/infra/database/dexie/service';
|
||||
import { DexieRepository } from 'src/app/infra/repository/dexie/dexie-repository.service';
|
||||
import { IGetUserPhotoByAttachmentId, IGetUserPhotoByAttachmentIdInputSchema, IUserPhotoRemoteRepository } from 'src/app/core/chat/repository/user-photo/user-photo-remote-repository';
|
||||
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
||||
import { SafeValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { z } from 'zod';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserPhotoRemoteRepository extends DexieRepository<UserPhotoTable, UserPhotoTable> implements IUserPhotoLocalRepository {
|
||||
constructor() {
|
||||
super(chatDatabase.userPhoto, UserPhotoTableSchema)
|
||||
export class UserPhotoRemoteRepositoryService implements IUserPhotoRemoteRepository{
|
||||
|
||||
constructor(
|
||||
private http: HttpAdapter
|
||||
) { }
|
||||
|
||||
@SafeValidateSchema(IGetUserPhotoByAttachmentIdInputSchema, 'GET/UserAuthentication/GetPhoto?UserPhoto=')
|
||||
getUserPhotoByAttachmentId(input: IGetUserPhotoByAttachmentId) {
|
||||
const geturl = environment.apiURL + `UserAuthentication/GetPhoto?UserPhoto=${input.attachmentId}`;
|
||||
|
||||
return this.http.get<string>(geturl)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ import { MessageMarkAsReadInput } from "src/app/module/chat/domain/use-case/mess
|
||||
import { BoldRemoveByRoomIdInput, BoldRemoveByRoomIdService } from 'src/app/module/chat/domain/use-case/bold/bold-remove-by-room-id.service';
|
||||
import { MemberListHttpSyncUseCase } from 'src/app/module/chat/domain/use-case/member/member-list-http-sync-use-case.ts.service'
|
||||
import { RoomBoldSyncUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-bold-sync-use-case.service'
|
||||
import { RoomSetLastMessageService } from 'src/app/module/chat/domain/use-case/room/room-set-last-message.service'
|
||||
import { RoomSetLastMessageService } from 'src/app/module/chat/domain/use-case/room/room-set-last-message.service';
|
||||
import { IUserPhotoGetByIdInput, UserPhotoGetByIdUseCase } from 'src/app/module/chat/domain/use-case/user-photo/user-photo-get-by-id-use-case.service'
|
||||
export const InstanceId = uuidv4();
|
||||
|
||||
@Injectable({
|
||||
@@ -84,7 +85,8 @@ export class ChatServiceService {
|
||||
private BoldRemoveByRoomIdService: BoldRemoveByRoomIdService,
|
||||
private MemberListHttpSyncUseCase: MemberListHttpSyncUseCase, // dont remove
|
||||
private RoomBoldSyncUseCaseService: RoomBoldSyncUseCaseService, // dont remove
|
||||
private RoomSetLastMessageService: RoomSetLastMessageService // dont remove
|
||||
private RoomSetLastMessageService: RoomSetLastMessageService, // dont remove
|
||||
private UserPhotoGetByIdUseCase: UserPhotoGetByIdUseCase
|
||||
) {
|
||||
this.MessageSocketRepositoryService.listenToDeleteMessages()
|
||||
.pipe()
|
||||
@@ -155,6 +157,10 @@ export class ChatServiceService {
|
||||
return this.MessageDeleteLiveUseCaseService.execute(params)
|
||||
}
|
||||
|
||||
getUserPhoto(input: IUserPhotoGetByIdInput) {
|
||||
return this.UserPhotoGetByIdUseCase.execute(input)
|
||||
}
|
||||
|
||||
reactToMessage(input: MessageReactionInput) {
|
||||
return this.MessageReactionUseCaseService.execute(input);
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IUserPhotoLocalRepository } from 'src/app/core/chat/repository/user-photo/user-photo-local-repository';
|
||||
import { IUserPhotoRemoteRepository } from 'src/app/core/chat/repository/user-photo/user-photo-remote-repository';
|
||||
import { UserPhotoTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/user-foto';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UserPhotoGetByIdInputSchema = UserPhotoTableSchema.pick({
|
||||
attachmentId: true,
|
||||
wxUserId: true,
|
||||
})
|
||||
|
||||
export type IUserPhotoGetByIdInput = z.infer<typeof UserPhotoGetByIdInputSchema>
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserPhotoGetByIdUseCase {
|
||||
|
||||
constructor(
|
||||
private userPhotoLocalRepository: IUserPhotoLocalRepository,
|
||||
private userPhotoRemoteRepository: IUserPhotoRemoteRepository
|
||||
) { }
|
||||
|
||||
async execute(input: IUserPhotoGetByIdInput) {
|
||||
|
||||
const result = await this.userPhotoLocalRepository.findOne({wxUserId: input.wxUserId})
|
||||
if(result.isOk() && result.value) {
|
||||
return result.map(e => {
|
||||
return e.file
|
||||
})
|
||||
} else if(result.isOk() && !result.value) {
|
||||
const remoteResult = await this.userPhotoRemoteRepository.getUserPhotoByAttachmentId({attachmentId: input.attachmentId})
|
||||
|
||||
if(remoteResult.isOk()) {
|
||||
this.userPhotoLocalRepository.insert({
|
||||
wxUserId: input.wxUserId,
|
||||
file: remoteResult.value.data,
|
||||
attachmentId: input.attachmentId
|
||||
})
|
||||
}
|
||||
|
||||
return remoteResult.map(e => {
|
||||
return e.data
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user