fix delete member and add member

This commit is contained in:
Peter Maquiran
2024-09-17 17:28:50 +01:00
parent 1bc5707321
commit 263f593260
9 changed files with 33 additions and 31 deletions
+17 -17
View File
@@ -63,34 +63,34 @@ export class RoomEntity extends BaseEntity<RoomEntity>(RoomEntitySchema) implem
if(data.roomType == RoomType.Direct) {
this.setName()
}
if(!this.$id) {
this.setLocalId()
}
if(!this.$id) {
this.$id = this.getReceiverId()
}
if(this.roomType == RoomType.Direct && !this.receiverId && this.members.length == 2) {
this.setReceiver()
if(!this.receiverId && this.members.length == 2) {
this.setReceiver()
}
}
}
// direct room only
getReceiverId() {
const receiver = this.members?.find((e) => e.user.wxUserId != SessionStore.user.UserId)
return receiver.user.wxUserId.toString()
}
// direct room only
setLocalId() {
const receiver = this.members?.find((e) => e.user.wxUserId != SessionStore.user.UserId)
if(receiver) {
this.$id =receiver.user.wxUserId.toString()
}
this.$id = this.getReceiverId()
}
// direct room only
setReceiver() {
const receiver = this.members?.find((e) => e.user.wxUserId != SessionStore.user.UserId)
if(receiver) {
this.receiverId = receiver.user.wxUserId
}
this.receiverId = parseInt(this.getReceiverId())
}
// direct room only
setName() {
const userChatName = this.members?.find((e) => e.user.wxUserId != SessionStore.user.UserId)
if(userChatName) {
@@ -25,7 +25,7 @@ export class MemberListRemoteRepository implements IMemberRemoteRepository {
@ValidateSchema(UserRemoveListInputDTOSchema)
async removeMemberFromRoom(data: UserRemoveListInputDTO): Promise<Result<any ,any>> {
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${data.id}/Member`, {members:data.members});
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${data.id}/Member`, {} , {members:data.members});
}
async setAmin(data: MemberSetAdminDTO): Promise<Result<any ,any>> {
@@ -50,7 +50,6 @@ export class SyncAllRoomMessagesService {
if (result.isOk()) {
const { addedItems, changedItems, deletedItems } = messageListDetermineChanges(result.value.data, localResult);
console.log({changedItems})
for (const message of changedItems) {
let clone: MessageTable = { ...message, roomId: room.id };
@@ -89,7 +89,7 @@ export class RoomBoldSyncUseCaseService {
await this.boldLocalRepository.open()
const result = await this.boldLocalRepository.findOne({roomId: newMessage.roomId})
if(result.isOk() && !result.value?.bold) {
if(result.isOk() && !result.value) {
const result = await this.boldLocalRepository.insert({roomId: newMessage.roomId, bold: 1})
} else if(result.isOk() && result.value.bold == 0) {
const result = await this.boldLocalRepository.update(newMessage.roomId, {bold: 1})
+3 -3
View File
@@ -98,7 +98,7 @@ export class HttpService {
}
async delete<T>(url: string, httpParamsObj = {}): Promise<Result<T, HttpErrorResponse>> {
async delete<T>(url: string, httpParamsObj = {}, body = {}): Promise<Result<T, HttpErrorResponse>> {
let httpParams = new HttpParams();
@@ -110,7 +110,8 @@ export class HttpService {
}
let opts = {
params : httpParams
params : httpParams,
body
}
try {
@@ -121,7 +122,6 @@ export class HttpService {
}
}
async patch<T>(url: string, body ={}): Promise<Result<T, HttpErrorResponse>> {
try {
const result = await this.http.patch<T>(url, body).toPromise();
+1 -1
View File
@@ -356,7 +356,7 @@ export class ChatPage implements OnInit {
this.showMessages = true;
}
} else {
console.log('conversa não existe');
console.log('conversa não existe', $roomId);
// this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
}
@@ -1005,7 +1005,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
openGroupContactsPage() {
this.openGroupContacts.emit(this.room.$id);
this.openGroupContacts.emit(this.room.id);
}
async takePictureMobile() {