mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix direct room
This commit is contained in:
@@ -3,6 +3,7 @@ import { BaseEntity } from "src/app/utils/entity";
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { MessageEntitySchema } from "./message";
|
import { MessageEntitySchema } from "./message";
|
||||||
import { IDBoolean } from "src/app/infra/database/dexie/type";
|
import { IDBoolean } from "src/app/infra/database/dexie/type";
|
||||||
|
import { Logger } from "src/app/services/logger/main/service";
|
||||||
|
|
||||||
export enum RoomType {
|
export enum RoomType {
|
||||||
Group = 1,
|
Group = 1,
|
||||||
@@ -53,7 +54,7 @@ export class RoomEntity extends BaseEntity<RoomEntity>(RoomEntitySchema) implem
|
|||||||
createdAt: typeof RoomEntitySchema._input.createdAt
|
createdAt: typeof RoomEntitySchema._input.createdAt
|
||||||
expirationDate: typeof RoomEntitySchema._input.expirationDate
|
expirationDate: typeof RoomEntitySchema._input.expirationDate
|
||||||
roomType: typeof RoomEntitySchema._input.roomType
|
roomType: typeof RoomEntitySchema._input.roomType
|
||||||
members: typeof RoomEntitySchema._input.members
|
members: typeof RoomEntitySchema._input.members = []
|
||||||
messages: typeof RoomEntitySchema._input.messages
|
messages: typeof RoomEntitySchema._input.messages
|
||||||
receiverId: typeof RoomEntitySchema._input.receiverId
|
receiverId: typeof RoomEntitySchema._input.receiverId
|
||||||
|
|
||||||
@@ -64,20 +65,30 @@ export class RoomEntity extends BaseEntity<RoomEntity>(RoomEntitySchema) implem
|
|||||||
if(data.roomType == RoomType.Direct) {
|
if(data.roomType == RoomType.Direct) {
|
||||||
this.setName()
|
this.setName()
|
||||||
|
|
||||||
if(!this.$id) {
|
if(this.members.length == 2) {
|
||||||
this.$id = this.getReceiverId()
|
if(!this.$id ) {
|
||||||
|
this.$id = this.getReceiverId()
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.receiverId ) {
|
||||||
|
this.setReceiver()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.receiverId && this.members.length == 2) {
|
|
||||||
this.setReceiver()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct room only
|
// direct room only
|
||||||
getReceiverId() {
|
getReceiverId() {
|
||||||
const receiver = this.members?.find((e) => e.user.wxUserId != SessionStore.user.UserId)
|
const receiver = this.members?.find((e) => e.user.wxUserId != SessionStore.user.UserId)
|
||||||
return receiver.user.wxUserId.toString()
|
if(receiver) {
|
||||||
|
return receiver.user.wxUserId.toString()
|
||||||
|
} else {
|
||||||
|
Logger.error('cant get receiver Id from Room.getReceiverId '+ this.id, this)
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct room only
|
// direct room only
|
||||||
@@ -87,7 +98,13 @@ export class RoomEntity extends BaseEntity<RoomEntity>(RoomEntitySchema) implem
|
|||||||
|
|
||||||
// direct room only
|
// direct room only
|
||||||
setReceiver() {
|
setReceiver() {
|
||||||
this.receiverId = parseInt(this.getReceiverId())
|
const receiverId = this.getReceiverId()
|
||||||
|
if(receiverId) {
|
||||||
|
this.receiverId = parseInt(receiverId)
|
||||||
|
} else {
|
||||||
|
Logger.error('cant set receiver Id from Room.setReceiver', this)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct room only
|
// direct room only
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { MessageTable } from "src/app/infra/database/dexie/instance/chat/schema/message";
|
import { MessageTable } from "src/app/infra/database/dexie/instance/chat/schema/message";
|
||||||
import { DexieRepository } from "src/app/infra/repository/dexie/dexie-repository.service";
|
import { DexieRepository } from "src/app/infra/repository/dexie/dexie-repository.service";
|
||||||
import { MessageEntity } from "../../entity/message";
|
|
||||||
import { Observable as DexieObservable, PromiseExtended } from 'Dexie';
|
|
||||||
import { AttachmentTable } from "src/app/infra/database/dexie/instance/chat/schema/attachment";
|
|
||||||
import { RoomTable } from "src/app/infra/database/dexie/instance/chat/schema/room";
|
import { RoomTable } from "src/app/infra/database/dexie/instance/chat/schema/room";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
export abstract class IRoomLocalRepository extends DexieRepository<RoomTable, RoomTable> {
|
export abstract class IRoomLocalRepository extends DexieRepository<RoomTable, RoomTable> {
|
||||||
abstract getItemsLive(): Observable<RoomTable[]>
|
abstract getItemsLive(): Observable<RoomTable[]>
|
||||||
abstract getRoomByIdLive(id: any) : Observable<RoomTable>
|
abstract getRoomByIdLive(id: any) : Observable<RoomTable>
|
||||||
|
abstract OnSetIdToDirectRoom(): Observable<MessageTable>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const MessageTableSchema = z.object({
|
|||||||
$id: z.string().optional(),
|
$id: z.string().optional(),
|
||||||
$createAt: z.number().optional(),
|
$createAt: z.number().optional(),
|
||||||
id: z.string().uuid().optional(),
|
id: z.string().uuid().optional(),
|
||||||
roomId: z.string().optional(),
|
roomId: z.string().uuid().optional(),
|
||||||
message: z.string().nullable().optional(),
|
message: z.string().nullable().optional(),
|
||||||
requestId: z.string().nullable().optional(),
|
requestId: z.string().nullable().optional(),
|
||||||
messageType: z.number(),
|
messageType: z.number(),
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ export class SignalRConnection {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
|
console.log(error);
|
||||||
resolve(err({
|
resolve(err({
|
||||||
type: EnumSocketError.catch
|
type: EnumSocketError.catch
|
||||||
}))
|
}))
|
||||||
@@ -144,6 +145,7 @@ export class SignalRConnection {
|
|||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
console.log('dfdf');
|
||||||
this.sendLaterSubject.next({method: 'SendMessage', args: input})
|
this.sendLaterSubject.next({method: 'SendMessage', args: input})
|
||||||
return resolve(err(false))
|
return resolve(err(false))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ export function roomListDetermineChanges(serverRooms: RoomListItemOutPutDTO[], l
|
|||||||
const roomsToUpdate = serverRooms.filter(room => {
|
const roomsToUpdate = serverRooms.filter(room => {
|
||||||
const localRoom = localRoomMap.get(room.chatRoom.id);
|
const localRoom = localRoomMap.get(room.chatRoom.id);
|
||||||
|
|
||||||
|
console.log(room.chatRoom, localRoom)
|
||||||
|
|
||||||
return localRoom && (
|
return localRoom && (
|
||||||
room.chatRoom.roomName !== localRoom.roomName && room.chatRoom.roomType == RoomType.Group ||
|
room.chatRoom.roomName !== localRoom.roomName && room.chatRoom.roomType == RoomType.Group ||
|
||||||
room.chatRoom.createdBy.wxUserId !== localRoom.createdBy.wxUserId ||
|
room.chatRoom.createdBy.wxUserId !== localRoom.createdBy.wxUserId ||
|
||||||
room.chatRoom.createdAt !== localRoom.createdAt ||
|
room.chatRoom.createdAt !== localRoom.createdAt
|
||||||
room.chatRoom.expirationDate !== localRoom.expirationDate // ||
|
//room.chatRoom.expirationDate !== localRoom.expirationDate // ||
|
||||||
// room.chatRoom.messages?.[0]?.id !== localRoom.messages?.[0]?.id
|
// room.chatRoom.messages?.[0]?.id !== localRoom.messages?.[0]?.id
|
||||||
// room.chatRoom.roomType !== localRoom.roomType
|
// room.chatRoom.roomType !== localRoom.roomType
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ export class RoomLocalRepository extends DexieRepository<RoomTable, RoomTable> i
|
|||||||
(modifications as Partial<RoomTable>).local = IDBoolean.true
|
(modifications as Partial<RoomTable>).local = IDBoolean.true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((modifications as Partial<RoomTable>).id && !oldValue.id && oldValue.roomType == RoomType.Direct) {
|
||||||
|
return this.listenCreateSyncSubject.next({...oldValue, ...modifications})
|
||||||
|
}
|
||||||
|
|
||||||
return modifications
|
return modifications
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,5 +64,10 @@ export class RoomLocalRepository extends DexieRepository<RoomTable, RoomTable> i
|
|||||||
return from(liveQuery(() => chatDatabase.room.get(id)));
|
return from(liveQuery(() => chatDatabase.room.get(id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OnSetIdToDirectRoom() {
|
||||||
|
return this.listenCreateSyncSubject.asObservable()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import { BoldRemoveByRoomIdInput, BoldRemoveByRoomIdService } from 'src/app/modu
|
|||||||
import { MemberListHttpSyncUseCase } from 'src/app/module/chat/domain/use-case/member/member-list-http-sync-use-case.ts.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 { 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 { RoomDirectOnSetIdUseCaseInputSchema, RoomDirectOnSetIdUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-direct-on-set-id-use-case.service';
|
||||||
import { RoomCreateLocalDirectMessageInputDTOInputDTO, RoomCreateLocalDirectMessageService } from 'src/app/module/chat/domain/use-case/room/room-create-local-direct-message.service';
|
import { RoomCreateLocalDirectMessageInputDTOInputDTO, RoomCreateLocalDirectMessageService } from 'src/app/module/chat/domain/use-case/room/room-create-local-direct-message.service';
|
||||||
import { RoomGetListOnCreateUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-get-list-on-create-use-case.service';
|
import { RoomGetListOnCreateUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-get-list-on-create-use-case.service';
|
||||||
import { IRoomSetLocalToFalseByIdInput, RoomSetLocalToFalseByIdService } from 'src/app/module/chat/domain/use-case/room/room-set-local-to-false-by-id.service';
|
import { IRoomSetLocalToFalseByIdInput, RoomSetLocalToFalseByIdService } from 'src/app/module/chat/domain/use-case/room/room-set-local-to-false-by-id.service';
|
||||||
@@ -115,7 +116,8 @@ export class ChatServiceService {
|
|||||||
private messageLocalGetByIdService: MessageLocalGetByIdService,
|
private messageLocalGetByIdService: MessageLocalGetByIdService,
|
||||||
private roomGetLocalByIdService: RoomGetLocalByIdService,
|
private roomGetLocalByIdService: RoomGetLocalByIdService,
|
||||||
private roomSetLocalToFalseByIdService: RoomSetLocalToFalseByIdService,
|
private roomSetLocalToFalseByIdService: RoomSetLocalToFalseByIdService,
|
||||||
private roomUpdateNameSyncService: RoomUpdateNameSyncService
|
private roomUpdateNameSyncService: RoomUpdateNameSyncService,
|
||||||
|
private RoomDirectOnSetIdUseCaseService: RoomDirectOnSetIdUseCaseService
|
||||||
) {
|
) {
|
||||||
this.MessageSocketRepositoryService.listenToDeleteMessages()
|
this.MessageSocketRepositoryService.listenToDeleteMessages()
|
||||||
.pipe()
|
.pipe()
|
||||||
@@ -187,6 +189,10 @@ export class ChatServiceService {
|
|||||||
return this.RemoveMemberUseCaseService.execute(data)
|
return this.RemoveMemberUseCaseService.execute(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
roomDirectOnSetId(input: RoomDirectOnSetIdUseCaseInputSchema) {
|
||||||
|
return this.RoomDirectOnSetIdUseCaseService.execute(input)
|
||||||
|
}
|
||||||
|
|
||||||
messageDelete(data: {roomId, messageId}) {
|
messageDelete(data: {roomId, messageId}) {
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { RoomType } from 'src/app/core/chat/entity/group';
|
import { RoomType } from 'src/app/core/chat/entity/group';
|
||||||
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||||
|
import { IDBoolean } from 'src/app/infra/database/dexie/type';
|
||||||
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
|
import { ContactRepositoryService } from 'src/app/services/Repositorys/contacts/repository/contacts-repository.service';
|
||||||
|
import { SessionStore } from 'src/app/store/session.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -20,12 +22,13 @@ export class ContactListService {
|
|||||||
])
|
])
|
||||||
|
|
||||||
if(userContact.isOk() && localDirectRooms.isOk()) {
|
if(userContact.isOk() && localDirectRooms.isOk()) {
|
||||||
const existNames = localDirectRooms.value.map(e => e.roomName);
|
const existNames = localDirectRooms.value.filter(e => e.local == IDBoolean.false).map(e => e.roomName);
|
||||||
|
//const existNames = localDirectRooms.value.map(e => e.roomName);
|
||||||
|
|
||||||
return userContact.map((list) => {
|
return userContact.map((list) => {
|
||||||
|
|
||||||
return list.data.result.filter((e) => {
|
return list.data.result.filter((e) => {
|
||||||
return !existNames.includes(e.wxFullName)
|
return !existNames.includes(e.wxFullName) && e.wxUserId != SessionStore.user.UserId
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else if (userContact.isErr()) {
|
} else if (userContact.isErr()) {
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export class MessageCreateUseCaseService {
|
|||||||
$id : message.$id
|
$id : message.$id
|
||||||
}
|
}
|
||||||
|
|
||||||
this.messageLocalDataSourceService.update(message.$id, {...clone, sending: false, roomId: message.roomId}).then((data)=> {
|
this.messageLocalDataSourceService.update(message.$id, {...clone, sending: false, roomId: clone.roomId}).then((data)=> {
|
||||||
if(data.isOk()) {
|
if(data.isOk()) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { filter } from 'rxjs/operators';
|
||||||
|
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
const RoomDirectOnSetIdUseCaseInputSchema = z.object({
|
||||||
|
$roomId: z.string()
|
||||||
|
})
|
||||||
|
|
||||||
|
export type RoomDirectOnSetIdUseCaseInputSchema = z.infer<typeof RoomDirectOnSetIdUseCaseInputSchema>
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class RoomDirectOnSetIdUseCaseService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private roomLocalRepository: IRoomLocalRepository
|
||||||
|
) { }
|
||||||
|
|
||||||
|
execute(input: RoomDirectOnSetIdUseCaseInputSchema) {
|
||||||
|
|
||||||
|
return this.roomLocalRepository.OnSetIdToDirectRoom().pipe(
|
||||||
|
filter((data)=> data?.$id == input.$roomId)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -70,7 +70,7 @@ export class GetRoomListUseCaseService {
|
|||||||
const filterValidateRooms = result.value.data.filter(e => {
|
const filterValidateRooms = result.value.data.filter(e => {
|
||||||
if(e.chatRoom.roomType == RoomType.Direct) {
|
if(e.chatRoom.roomType == RoomType.Direct) {
|
||||||
|
|
||||||
if(e.chatRoom.user1 != null && e.chatRoom.user2 != null) {
|
if(e.chatRoom.user1 != null && e.chatRoom.user2 != null || e.chatRoom.user1?.wxUserId == e.chatRoom.user2?.wxUserId) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
Logger.error("direct room invalid data", {
|
Logger.error("direct room invalid data", {
|
||||||
@@ -92,18 +92,25 @@ export class GetRoomListUseCaseService {
|
|||||||
const roomsToInsertEntity = GetRoomListMapper.toDomain(roomsToInsert)
|
const roomsToInsertEntity = GetRoomListMapper.toDomain(roomsToInsert)
|
||||||
for( const room of roomsToInsertEntity) {
|
for( const room of roomsToInsertEntity) {
|
||||||
|
|
||||||
this.roomLocalDataSourceService.insert(room).then((result) => {
|
if(room.roomType == RoomType.Direct) {
|
||||||
|
if(room.$id) {
|
||||||
|
this.roomLocalDataSourceService.insert(room).then((result) => {
|
||||||
|
|
||||||
if( result.isErr() &&
|
if( result.isErr() &&
|
||||||
room.roomType == RoomType.Direct &&
|
result.error.DBErrorName == 'ConstraintError') {
|
||||||
result.error.DBErrorName == 'ConstraintError') {
|
this.roomLocalDataSourceService.update(room.$id, room).then((result) => {
|
||||||
this.roomLocalDataSourceService.update(room.$id, room).then((result) => {
|
if(result.isErr()) {
|
||||||
if(result.isErr()) {
|
console.log('failed to update room id')
|
||||||
console.log('failed to update room id')
|
}
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
} else {
|
||||||
|
this.roomLocalDataSourceService.insert(room)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(room.expirationDate) {
|
if(room.expirationDate) {
|
||||||
this.CronJobService.createCronJob('remove expired room', new Date(room.expirationDate), this.execute)
|
this.CronJobService.createCronJob('remove expired room', new Date(room.expirationDate), this.execute)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export class RoomSetLastMessageService {
|
|||||||
|
|
||||||
for(const room of roomList) {
|
for(const room of roomList) {
|
||||||
if(room.messages?.[0]?.id == message.id) {
|
if(room.messages?.[0]?.id == message.id) {
|
||||||
console.log('listenToUpdateMessage', message.roomId)
|
|
||||||
|
|
||||||
const result = await this.roomLocalRepository.update(room.$id, {
|
const result = await this.roomLocalRepository.update(room.$id, {
|
||||||
messages: [message]
|
messages: [message]
|
||||||
@@ -51,7 +50,7 @@ export class RoomSetLastMessageService {
|
|||||||
if(result.isErr()) {
|
if(result.isErr()) {
|
||||||
console.log('failed to update last message')
|
console.log('failed to update last message')
|
||||||
} else {
|
} else {
|
||||||
console.log('set last message')
|
// console.log('set last message')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { RoomViewModel } from './store/model/room';
|
|||||||
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service'
|
import { MessageLocalDataSourceService } from 'src/app/module/chat/data/repository/message/message-local-data-source.service'
|
||||||
import { ToastService } from 'src/app/services/toast.service';
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
import { Logger } from 'src/app/services/logger/main/service';
|
import { Logger } from 'src/app/services/logger/main/service';
|
||||||
|
import { IDBoolean } from 'src/app/infra/database/dexie/type';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-chat',
|
selector: 'app-chat',
|
||||||
templateUrl: './chat.page.html',
|
templateUrl: './chat.page.html',
|
||||||
@@ -110,8 +111,8 @@ export class ChatPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updatemessage(sortedRooms) {
|
updatemessage(sortedRooms: RoomViewModel[]) {
|
||||||
this.rooms = sortedRooms
|
this.rooms = sortedRooms.filter(e => e.local == IDBoolean.false)
|
||||||
|
|
||||||
this.rooms.sort((a, b) =>
|
this.rooms.sort((a, b) =>
|
||||||
new Date(b.messages?.[0]?.sentAt as string || b.createdAt ).getTime() -
|
new Date(b.messages?.[0]?.sentAt as string || b.createdAt ).getTime() -
|
||||||
@@ -347,7 +348,7 @@ export class ChatPage implements OnInit {
|
|||||||
this.RoomSelected = exist
|
this.RoomSelected = exist
|
||||||
this.selectedRoomId = exist.$id;
|
this.selectedRoomId = exist.$id;
|
||||||
if (window.innerWidth < 701) {
|
if (window.innerWidth < 701) {
|
||||||
this.openMessagesModal($roomId);
|
this.openMessagesModal(this.RoomSelected);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.selectedRoomId = $roomId;
|
this.selectedRoomId = $roomId;
|
||||||
@@ -378,7 +379,7 @@ export class ChatPage implements OnInit {
|
|||||||
|
|
||||||
openMessagesToStartDirectConversation(room: RoomViewModel) {
|
openMessagesToStartDirectConversation(room: RoomViewModel) {
|
||||||
if (window.innerWidth < 701) {
|
if (window.innerWidth < 701) {
|
||||||
// this.openMessagesModal(roomId);
|
this.openMessagesModal(room);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.roomId = null;
|
this.roomId = null;
|
||||||
@@ -460,10 +461,8 @@ export class ChatPage implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
modal.onDidDismiss().then((Data) => {
|
modal.onDidDismiss().then((Data) => {
|
||||||
|
console.log('Data', Data.data)
|
||||||
// let data = Data.data
|
this.openMessagesToStartDirectConversation(Data.data);
|
||||||
// let roomId = data.roomId
|
|
||||||
// this.openMessagesPage(roomId);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -497,7 +496,7 @@ export class ChatPage implements OnInit {
|
|||||||
await modal.present();
|
await modal.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
async openMessagesModal(roomId: any) {
|
async openMessagesModal(room: RoomViewModel) {
|
||||||
this.closeAllDesktopComponents();
|
this.closeAllDesktopComponents();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -506,7 +505,7 @@ export class ChatPage implements OnInit {
|
|||||||
component: MessagesPage,
|
component: MessagesPage,
|
||||||
cssClass: 'modal modal-desktop isMessagesChatOpened',
|
cssClass: 'modal modal-desktop isMessagesChatOpened',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
roomId: roomId,
|
room: room,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await modal.present();
|
await modal.present();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<ion-list class="header-bottom-contacts" *ngIf="roomMembers$ | async as memberList" >
|
<ion-list class="header-bottom-contacts" *ngIf="roomMembers$ | async as memberList" >
|
||||||
<ng-container *ngFor="let user of memberList; let i = index">
|
<ng-container *ngFor="let user of memberList; let i = index">
|
||||||
<span *ngIf="roomType == RoomTypeEnum.Group"> {{ user.wxFullName }}<ng-container *ngIf="i < memberList.length - 1">, </ng-container> </span>
|
<span > {{ user.wxFullName }}<ng-container *ngIf="i < memberList.length - 1">, </ng-container> </span>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
@Input() _room!: RoomViewModel
|
@Input() _room!: RoomViewModel
|
||||||
room!: RoomViewModel
|
room!: RoomViewModel
|
||||||
|
|
||||||
@Input() roomId: string;
|
|
||||||
@Input() showMessages: string;
|
|
||||||
|
|
||||||
@Output() openNewEventPage: EventEmitter<any> = new EventEmitter<any>();
|
@Output() openNewEventPage: EventEmitter<any> = new EventEmitter<any>();
|
||||||
@Output() getDirectMessages: EventEmitter<any> = new EventEmitter<any>();
|
@Output() getDirectMessages: EventEmitter<any> = new EventEmitter<any>();
|
||||||
@@ -142,6 +140,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
messageSendSubject: Subscription
|
messageSendSubject: Subscription
|
||||||
messageTypingSubject: Subscription
|
messageTypingSubject: Subscription
|
||||||
messageOnReconnectSubject: Subscription
|
messageOnReconnectSubject: Subscription
|
||||||
|
messageOnSetRoomId: Subscription
|
||||||
|
|
||||||
messages1: {[key: string]: MessageViewModal[]} = {}
|
messages1: {[key: string]: MessageViewModal[]} = {}
|
||||||
MessageAttachmentFileType = MessageAttachmentFileType
|
MessageAttachmentFileType = MessageAttachmentFileType
|
||||||
@@ -155,6 +154,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
date: {[key: string]: Object} = {}
|
date: {[key: string]: Object} = {}
|
||||||
handleClickActive = true
|
handleClickActive = true
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public popoverController: PopoverController,
|
public popoverController: PopoverController,
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
@@ -188,7 +188,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
|
||||||
this.room = {...this._room} as any
|
this.room = {...this._room} as any
|
||||||
console.log('message', this.room)
|
|
||||||
if(this.room.local == IDBoolean.false) {
|
if(this.room.local == IDBoolean.false) {
|
||||||
this.getMessages()
|
this.getMessages()
|
||||||
this.subscribeToChanges()
|
this.subscribeToChanges()
|
||||||
@@ -204,6 +204,30 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
this.roomType = e.roomType;
|
this.roomType = e.roomType;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.messageOnSetRoomId?.unsubscribe()
|
||||||
|
|
||||||
|
if(this.room.local == IDBoolean.true) {
|
||||||
|
this.messageOnSetRoomId = this.chatServiceService.roomDirectOnSetId({$roomId: this.room.$id}).subscribe((data) => {
|
||||||
|
this.messageOnSetRoomId?.unsubscribe()
|
||||||
|
|
||||||
|
this.room = new RoomViewModel(data)
|
||||||
|
|
||||||
|
const hasMyMessage = this.messages1[this.room.$id].find(e => e.sender.wxUserId == SessionStore.user.UserId)
|
||||||
|
|
||||||
|
if(!hasMyMessage) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.getMessages()
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.subscribeToChanges()
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribeToChanges() {
|
subscribeToChanges() {
|
||||||
@@ -246,9 +270,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
|
|
||||||
updateRoomDetails() {
|
updateRoomDetails() {
|
||||||
if(!this.room?.local) {
|
this.chatServiceService.getRoomById(this.room.id)
|
||||||
this.chatServiceService.getRoomById(this.room.id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeBold() {
|
removeBold() {
|
||||||
@@ -420,7 +442,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
memberId: SessionStore.user.UserId,
|
memberId: SessionStore.user.UserId,
|
||||||
messageId: message.id,
|
messageId: message.id,
|
||||||
requestId: '',
|
requestId: '',
|
||||||
roomId: this.room.$id
|
roomId: this.room.id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -506,8 +528,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
const index = this.messages1[this.room.$id].findIndex(e => e?.id === updateMessage.id); // Use triple equals for comparison
|
const index = this.messages1[this.room.$id].findIndex(e => e?.id === updateMessage.id); // Use triple equals for comparison
|
||||||
|
|
||||||
console.log('updateMessage', updateMessage)
|
|
||||||
|
|
||||||
if (index !== -1) { // Check if the item was found
|
if (index !== -1) { // Check if the item was found
|
||||||
this.messages1[this.room.$id][index].info = updateMessage.info
|
this.messages1[this.room.$id][index].info = updateMessage.info
|
||||||
this.messages1[this.room.$id][index].message = updateMessage.message
|
this.messages1[this.room.$id][index].message = updateMessage.message
|
||||||
@@ -580,6 +600,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
sendTyping() {
|
sendTyping() {
|
||||||
if(this.room.local == IDBoolean.false) {
|
if(this.room.local == IDBoolean.false) {
|
||||||
this.UserTypingRemoteRepositoryService.sendTyping(this.room.id)
|
this.UserTypingRemoteRepositoryService.sendTyping(this.room.id)
|
||||||
|
} else {
|
||||||
|
console.log('dont send')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,8 +790,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
|
|
||||||
if(this.room.id) {
|
if(this.room.id) {
|
||||||
message.roomId = this.room.id
|
message.roomId = this.room.id
|
||||||
} else {
|
|
||||||
message.roomId = this.room.$id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message.sentAt = new Date().toISOString()
|
message.sentAt = new Date().toISOString()
|
||||||
@@ -792,7 +812,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
async messageResult(result: Promise<Result<MessageOutPutDataDTO, any>> ) {
|
async messageResult(result: Promise<Result<MessageOutPutDataDTO, any>> ) {
|
||||||
let message = await result
|
let message = await result
|
||||||
|
|
||||||
console.log('result', message)
|
|
||||||
|
|
||||||
if(message.isOk() && this.room.local == IDBoolean.true) {
|
if(message.isOk() && this.room.local == IDBoolean.true) {
|
||||||
this.room.local = IDBoolean.false;
|
this.room.local = IDBoolean.false;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { ToastService } from 'src/app/services/toast.service';
|
|||||||
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service'
|
import { ChatServiceService } from 'src/app/module/chat/domain/chat-service.service'
|
||||||
import { MessageEntity } from 'src/app/core/chat/entity/message';
|
import { MessageEntity } from 'src/app/core/chat/entity/message';
|
||||||
import { RoomType } from "src/app/core/chat/entity/group";
|
import { RoomType } from "src/app/core/chat/entity/group";
|
||||||
|
import { RoomViewModel } from '../../../store/model/room';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contacts',
|
selector: 'app-contacts',
|
||||||
@@ -69,12 +70,12 @@ export class ContactsPage implements OnInit {
|
|||||||
async loadUsers() {
|
async loadUsers() {
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const getallChatUsers = await this.contactsRepositoryService.getUsers()
|
const getallChatUsers = await this.chatServiceService.getContactList()
|
||||||
|
|
||||||
|
|
||||||
if(getallChatUsers.isOk()) {
|
if(getallChatUsers.isOk()) {
|
||||||
|
|
||||||
this.allChatUsers = getallChatUsers.value.data.result.sort((a,b) => {
|
this.allChatUsers = getallChatUsers.value.sort((a,b) => {
|
||||||
if(a.wxFullName < b.wxFullName) {
|
if(a.wxFullName < b.wxFullName) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -163,22 +164,34 @@ export class ContactsPage implements OnInit {
|
|||||||
this.modalController.dismiss({});
|
this.modalController.dismiss({});
|
||||||
}
|
}
|
||||||
|
|
||||||
select(user: UserContacts) {
|
async select(user: UserContacts) {
|
||||||
|
|
||||||
const message = new MessageEntity();
|
|
||||||
|
|
||||||
message.sender = {
|
// const result = await this.chatServiceService.sendMessage(message, RoomType.Direct)
|
||||||
userPhoto: '',
|
|
||||||
wxeMail: SessionStore.user.Email,
|
const result = await this.chatServiceService.roomCreateLocalDirectMessage({
|
||||||
wxFullName: SessionStore.user.FullName,
|
roomName: user.wxFullName,
|
||||||
wxUserId: SessionStore.user.UserId
|
receiverId: user.wxUserId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if(result.isOk()) {
|
||||||
|
|
||||||
|
const room = await this.chatServiceService.roomGetLocalById({
|
||||||
|
$roomId: result.value
|
||||||
|
})
|
||||||
|
|
||||||
|
if(room.isOk()) {
|
||||||
|
|
||||||
|
console.log('room', room)
|
||||||
|
console.log('result.value', result.value)
|
||||||
|
console.log('receiverId', user.wxUserId)
|
||||||
|
|
||||||
|
this.modalController.dismiss(new RoomViewModel(room.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
message.receiverId = user.wxUserId
|
|
||||||
|
|
||||||
message.message = 'hello'
|
|
||||||
|
|
||||||
this.chatServiceService.sendMessage(message, RoomType.Group)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="middle-container" *ngIf="!showMessageOptions">
|
<div class="middle-container" *ngIf="!showMessageOptions">
|
||||||
<div class="middle" >
|
<div class="middle" >
|
||||||
<ion-label *ngIf="roomData$ | async as roomData" class="title">{{ roomData.roomName }}</ion-label>
|
<ion-label class="title">{{ room?.roomName }}</ion-label>
|
||||||
<span *ngIf="roomStatus$ | async as roomStatus"><ion-icon *ngIf="roomStatus"
|
<span *ngIf="roomStatus$ | async as roomStatus"><ion-icon *ngIf="roomStatus"
|
||||||
class="online" name="ellipse"></ion-icon></span>
|
class="online" name="ellipse"></ion-icon></span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import { LastMessage } from '../../utils/lastMessage';
|
|||||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||||
import { FileSystemMobileService } from 'src/app/infra/file-system/mobile/file-system-mobile.service';
|
import { FileSystemMobileService } from 'src/app/infra/file-system/mobile/file-system-mobile.service';
|
||||||
|
import { RoomViewModel } from '../../store/model/room';
|
||||||
|
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
@@ -148,6 +149,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
IMessageType = IMessageType
|
IMessageType = IMessageType
|
||||||
handleClickActive = false
|
handleClickActive = false
|
||||||
|
|
||||||
|
room!: RoomViewModel
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public popoverController: PopoverController,
|
public popoverController: PopoverController,
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
@@ -178,6 +181,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
|
|
||||||
this.roomId = this.navParams.get('roomId');
|
this.roomId = this.navParams.get('roomId');
|
||||||
|
|
||||||
|
this.room = this.navParams.get('room');
|
||||||
|
|
||||||
|
console.log('room', this.room)
|
||||||
|
|
||||||
|
|
||||||
this.roomData$ = this.RoomLocalRepository.getRoomByIdLive(this.roomId)
|
this.roomData$ = this.RoomLocalRepository.getRoomByIdLive(this.roomId)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "263f59326",
|
"shortSHA": "eeaade9aa",
|
||||||
"SHA": "263f593260f41c86f36c984e82cd023adb6bdbd2",
|
"SHA": "eeaade9aabf2466b5d4d00c8a2acff737a984040",
|
||||||
"branch": "feature/chat-new-api-peter",
|
"branch": "feature/chat-new-api-peter",
|
||||||
"lastCommitAuthor": "'Peter Maquiran'",
|
"lastCommitAuthor": "'Peter Maquiran'",
|
||||||
"lastCommitTime": "'Tue Sep 17 17:28:50 2024 +0100'",
|
"lastCommitTime": "'Tue Sep 17 18:05:47 2024 +0100'",
|
||||||
"lastCommitMessage": "fix delete member and add member",
|
"lastCommitMessage": "update room bold",
|
||||||
"lastCommitNumber": "6077",
|
"lastCommitNumber": "6078",
|
||||||
"changeStatus": "On branch feature/chat-new-api-peter\nYour branch is ahead of 'origin/feature/chat-new-api-peter' by 5 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/core/chat/repository/room/room-socket-repository.ts\n\tmodified: src/app/module/chat/data/repository/room/room-socket-repository.service.ts\n\tmodified: src/app/module/chat/domain/chat-service.service.ts\n\tnew file: src/app/module/chat/domain/use-case/room/room-update-name-sync.service.ts\n\tmodified: src/app/ui/chat/chat.page.html",
|
"changeStatus": "On branch feature/chat-new-api-peter\nYour branch is ahead of 'origin/feature/chat-new-api-peter' by 6 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/core/chat/entity/group.ts\n\tmodified: src/app/core/chat/repository/room/room-local-repository.ts\n\tmodified: src/app/infra/database/dexie/instance/chat/schema/message.ts\n\tmodified: src/app/infra/socket/signalR/signalR.ts\n\tmodified: src/app/module/chat/data/async/list/rooms/roomListChangeDetector.ts\n\tmodified: src/app/module/chat/data/repository/room/room-local-repository.service.ts\n\tmodified: src/app/module/chat/domain/chat-service.service.ts\n\tmodified: src/app/module/chat/domain/use-case/contact/contact-list.service.ts\n\tmodified: src/app/module/chat/domain/use-case/message/message-create-use-case.service.ts\n\tnew file: src/app/module/chat/domain/use-case/room/room-direct-on-set-id-use-case.service.ts\n\tmodified: src/app/module/chat/domain/use-case/room/room-get-list-use-case.service.ts\n\tmodified: src/app/module/chat/domain/use-case/room/room-set-last-message.service.ts\n\tmodified: src/app/ui/chat/chat.page.ts\n\tmodified: src/app/ui/chat/component/messages/messages.page.html\n\tmodified: src/app/ui/chat/component/messages/messages.page.ts\n\tmodified: src/app/ui/chat/modal/messages/contacts/contacts.page.ts\n\tmodified: src/app/ui/chat/modal/messages/messages.page.html\n\tmodified: src/app/ui/chat/modal/messages/messages.page.ts\n\tmodified: version/git-version.ts",
|
||||||
"changeAuthor": "peter.maquiran"
|
"changeAuthor": "peter.maquiran"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user