mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
Fix office bugs (#5784)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
8e440b8f0f
commit
0c38c1b9ff
@ -162,7 +162,7 @@
|
||||
function checkRequests (requests: JoinRequest[], $myInfo: ParticipantInfo | undefined): void {
|
||||
if (activeRequest !== undefined) {
|
||||
// try to find active request, if it not exists close popup
|
||||
if (requests.find((r) => r._id === activeRequest?._id) === undefined) {
|
||||
if (requests.find((r) => r._id === activeRequest?._id && r.room === $myInfo?.room) === undefined) {
|
||||
closePopup(joinRequestCategory)
|
||||
activeRequest = undefined
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ export async function OnUserStatus (tx: Tx, control: TriggerControl): Promise<Tx
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
void removeUserInfo(status.user, control)
|
||||
}, 5000)
|
||||
}, 20000)
|
||||
return []
|
||||
}
|
||||
}
|
||||
@ -166,6 +166,32 @@ async function roomJoinHandler (info: ParticipantInfo, control: TriggerControl,
|
||||
}
|
||||
}
|
||||
|
||||
async function rejectJoinRequests (
|
||||
info: ParticipantInfo,
|
||||
control: TriggerControl,
|
||||
roomInfos: RoomInfo[]
|
||||
): Promise<Tx[]> {
|
||||
const res: Tx[] = []
|
||||
const oldRoomInfo = roomInfos.find((ri) => ri.persons.includes(info.person))
|
||||
if (oldRoomInfo !== undefined) {
|
||||
const restPersons = oldRoomInfo.persons.filter((p) => p !== info.person)
|
||||
if (restPersons.length === 0) {
|
||||
const requests = await control.findAll(love.class.JoinRequest, {
|
||||
room: oldRoomInfo.room,
|
||||
status: RequestStatus.Pending
|
||||
})
|
||||
for (const request of requests) {
|
||||
res.push(
|
||||
control.txFactory.createTxUpdateDoc(love.class.JoinRequest, love.space.Rooms, request._id, {
|
||||
status: RequestStatus.Rejected
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function setDefaultRoomAccess (info: ParticipantInfo, roomInfos: RoomInfo[], control: TriggerControl): Tx[] {
|
||||
const res: Tx[] = []
|
||||
const oldRoomInfo = roomInfos.find((ri) => ri.persons.includes(info.person))
|
||||
@ -209,6 +235,7 @@ export async function OnParticipantInfo (tx: Tx, control: TriggerControl): Promi
|
||||
const info = (await control.findAll(love.class.ParticipantInfo, { _id: actualTx.objectId }, { limit: 1 }))[0]
|
||||
if (info === undefined) return []
|
||||
const res: Tx[] = []
|
||||
res.push(...(await rejectJoinRequests(info, control, roomInfos)))
|
||||
res.push(...setDefaultRoomAccess(info, roomInfos, control))
|
||||
res.push(...(await roomJoinHandler(info, control, roomInfos)))
|
||||
return res
|
||||
|
Loading…
Reference in New Issue
Block a user