mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
change detector for room list
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn-no-color adicionar" (click)="updateGroup()">
|
||||
<ion-label>Adicionar bug</ion-label>
|
||||
<ion-label>Adicionar</ion-label>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -82,6 +82,8 @@ export class GroupContactsPage implements OnInit {
|
||||
const getallChatUsers = await this.contactsRepositoryService.getUsers()
|
||||
const getRoomById = await this.RoomRepositoryService.getRoomById(this.roomId)
|
||||
|
||||
console.log({getallChatUsers, getRoomById})
|
||||
|
||||
if(getallChatUsers.isOk() && getRoomById.isOk()) {
|
||||
|
||||
this.allChatUsers = getallChatUsers.value.data.result.sort((a,b) => {
|
||||
@@ -96,6 +98,8 @@ export class GroupContactsPage implements OnInit {
|
||||
|
||||
const currentMemberToMap = await this.RoomRepositoryService.getRoomMemberById(this.roomId)
|
||||
|
||||
console.log({currentMemberToMap})
|
||||
|
||||
this.currentMembers = currentMemberToMap.map((e)=> ({
|
||||
userPhoto: e.user.userPhoto,
|
||||
wxeMail: e.user.wxeMail,
|
||||
@@ -103,33 +107,41 @@ export class GroupContactsPage implements OnInit {
|
||||
wxUserId: e.user.wxUserId
|
||||
}))
|
||||
|
||||
|
||||
const currentMemberIds = this.currentMembers.map(e => e.wxUserId)
|
||||
|
||||
const allSelectableUsers = this.allChatUsers.filter(e => !currentMemberIds.includes(e.wxUserId))
|
||||
|
||||
for(const user of allSelectableUsers) {
|
||||
const firstLetter = user.wxFullName.charAt(0)
|
||||
|
||||
if(!this.userContainer[firstLetter]) {
|
||||
user['isChecked'] = false
|
||||
this.userContainer[firstLetter] = [user as any]
|
||||
} else {
|
||||
const userIds = this.userContainer[firstLetter].map( e => e.wxUserId)
|
||||
if(!userIds.includes(user.wxUserId)) {
|
||||
user['isChecked'] = false
|
||||
this.userContainer[firstLetter].push(user as any)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (getRoomById.isErr() && getRoomById.error instanceof HttpResponse) {
|
||||
this.httpErrorHandle.httpStatusHandle(getRoomById.error)
|
||||
} else if (getallChatUsers.isErr() && getallChatUsers.error instanceof HttpResponse) {
|
||||
this.httpErrorHandle.httpStatusHandle(getallChatUsers.error)
|
||||
} else if (getRoomById.isErr() ) {
|
||||
console.log(getRoomById.error)
|
||||
} else if (getallChatUsers.isErr() ) {
|
||||
console.log(getallChatUsers.error)
|
||||
} else {
|
||||
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
|
||||
}
|
||||
|
||||
const currentMemberIds = this.currentMembers.map(e => e.wxUserId)
|
||||
|
||||
const allSelectableUsers = this.allChatUsers.filter(e => !currentMemberIds.includes(e.wxUserId))
|
||||
|
||||
for(const user of allSelectableUsers) {
|
||||
const firstLetter = user.wxFullName.charAt(0)
|
||||
|
||||
if(!this.userContainer[firstLetter]) {
|
||||
user['isChecked'] = false
|
||||
this.userContainer[firstLetter] = [user as any]
|
||||
} else {
|
||||
const userIds = this.userContainer[firstLetter].map( e => e.wxUserId)
|
||||
if(!userIds.includes(user.wxUserId)) {
|
||||
user['isChecked'] = false
|
||||
this.userContainer[firstLetter].push(user as any)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user