Fix office bugs (#5784)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-06-12 12:12:13 +05:00 committed by GitHub
parent 8e440b8f0f
commit 0c38c1b9ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View File

@ -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
}

View File

@ -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