mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 11:42:30 +03:00
Validate meeting time (#6212)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
52df4cc869
commit
e1249789dc
@ -16,11 +16,11 @@
|
||||
import { Contact, Person } from '@hcengineering/contact'
|
||||
import { personByIdStore } from '@hcengineering/contact-resources'
|
||||
import { Ref } from '@hcengineering/core'
|
||||
import love, { Floor as FloorType, Meeting, Office, Room, RoomInfo, isOffice } from '@hcengineering/love'
|
||||
import love, { Floor as FloorType, Office, Room, RoomInfo, isOffice } from '@hcengineering/love'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { deviceOptionsStore as deviceInfo, getCurrentLocation, navigate } from '@hcengineering/ui'
|
||||
import { onMount, onDestroy } from 'svelte'
|
||||
import { activeFloor, floors, infos, invites, myInfo, myRequests, rooms } from '../stores'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { activeFloor, floors, infos, invites, myInfo, myRequests, rooms, storePromise } from '../stores'
|
||||
import { connectToMeeting, tryConnect } from '../utils'
|
||||
import Floor from './Floor.svelte'
|
||||
import FloorConfigure from './FloorConfigure.svelte'
|
||||
@ -64,9 +64,11 @@
|
||||
loc.query = Object.keys(query).length === 0 ? undefined : query
|
||||
navigate(loc, true)
|
||||
if (sessionId != null) {
|
||||
await $storePromise
|
||||
await connectToSession(sessionId)
|
||||
} else if (meetId != null) {
|
||||
await connectToMeeting($personByIdStore, $myInfo, $infos, $myRequests, $invites, $rooms, meetId)
|
||||
await $storePromise
|
||||
await connectToMeeting($personByIdStore, $myInfo, $infos, $myRequests, $invites, meetId)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
@ -31,7 +31,7 @@
|
||||
} from 'livekit-client'
|
||||
import { onDestroy, onMount, tick } from 'svelte'
|
||||
import love from '../plugin'
|
||||
import { currentRoom, infos, invites, myInfo, myRequests } from '../stores'
|
||||
import { storePromise, currentRoom, infos, invites, myInfo, myRequests } from '../stores'
|
||||
import {
|
||||
awaitConnect,
|
||||
isConnected,
|
||||
@ -221,6 +221,8 @@
|
||||
|
||||
configured = true
|
||||
|
||||
await $storePromise
|
||||
|
||||
if (!$isConnected && !$isCurrentInstanceConnected) {
|
||||
const info = $infos.filter((p) => p.room === room._id)
|
||||
await tryConnect($personByIdStore, $myInfo, room, info, $myRequests, $invites)
|
||||
|
@ -26,7 +26,7 @@
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
$: items = $rooms
|
||||
.filter((p) => !isOffice(p))
|
||||
.filter((p) => !isOffice(p) && p._id !== love.ids.Reception)
|
||||
.map((p) => {
|
||||
return {
|
||||
_id: p._id,
|
||||
|
@ -64,38 +64,72 @@ function filterParticipantInfo (value: ParticipantInfo[]): ParticipantInfo[] {
|
||||
return Array.from(map.values())
|
||||
}
|
||||
|
||||
export const storePromise = writable<Promise<void>>(new Promise((resolve) => {}))
|
||||
|
||||
function fillStores (): void {
|
||||
const client = getClient()
|
||||
if (client !== undefined) {
|
||||
const query = createQuery(true)
|
||||
query.query(love.class.Room, {}, (res) => {
|
||||
rooms.set(res)
|
||||
})
|
||||
const roomPromise = new Promise<void>((resolve) =>
|
||||
query.query(love.class.Room, {}, (res) => {
|
||||
rooms.set(res)
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
const statusQuery = createQuery(true)
|
||||
statusQuery.query(love.class.ParticipantInfo, {}, (res) => {
|
||||
infos.set(filterParticipantInfo(res))
|
||||
})
|
||||
const infoPromise = new Promise<void>((resolve) =>
|
||||
statusQuery.query(love.class.ParticipantInfo, {}, (res) => {
|
||||
infos.set(filterParticipantInfo(res))
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
const floorsQuery = createQuery(true)
|
||||
floorsQuery.query(love.class.Floor, {}, (res) => {
|
||||
floors.set(res)
|
||||
})
|
||||
const floorPromise = new Promise<void>((resolve) =>
|
||||
floorsQuery.query(love.class.Floor, {}, (res) => {
|
||||
floors.set(res)
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
const requestsQuery = createQuery(true)
|
||||
requestsQuery.query(
|
||||
love.class.JoinRequest,
|
||||
{ person: (getCurrentAccount() as PersonAccount).person, status: RequestStatus.Pending },
|
||||
(res) => {
|
||||
myRequests.set(res)
|
||||
}
|
||||
const requestPromise = new Promise<void>((resolve) =>
|
||||
requestsQuery.query(
|
||||
love.class.JoinRequest,
|
||||
{ person: (getCurrentAccount() as PersonAccount).person, status: RequestStatus.Pending },
|
||||
(res) => {
|
||||
myRequests.set(res)
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
)
|
||||
const preferencesQuery = createQuery(true)
|
||||
preferencesQuery.query(love.class.DevicesPreference, {}, (res) => {
|
||||
myPreferences.set(res[0])
|
||||
$myPreferences = res[0]
|
||||
})
|
||||
const preferencePromise = new Promise<void>((resolve) =>
|
||||
preferencesQuery.query(love.class.DevicesPreference, {}, (res) => {
|
||||
myPreferences.set(res[0])
|
||||
$myPreferences = res[0]
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
const invitesQuery = createQuery(true)
|
||||
invitesQuery.query(love.class.Invite, { status: RequestStatus.Pending }, (res) => {
|
||||
invites.set(res)
|
||||
})
|
||||
const invitesPromise = new Promise<void>((resolve) =>
|
||||
invitesQuery.query(love.class.Invite, { status: RequestStatus.Pending }, (res) => {
|
||||
invites.set(res)
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
storePromise.set(
|
||||
new Promise((resolve) => {
|
||||
void Promise.all([
|
||||
roomPromise,
|
||||
infoPromise,
|
||||
floorPromise,
|
||||
requestPromise,
|
||||
preferencePromise,
|
||||
invitesPromise
|
||||
]).then(() => {
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
)
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
fillStores()
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
import calendar, { type Event } from '@hcengineering/calendar'
|
||||
import calendar, { getAllEvents, type Event } from '@hcengineering/calendar'
|
||||
import contact, { getName, type Person, type PersonAccount } from '@hcengineering/contact'
|
||||
import core, {
|
||||
AccountRole,
|
||||
@ -573,16 +573,21 @@ export async function connectToMeeting (
|
||||
info: ParticipantInfo[],
|
||||
currentRequests: JoinRequest[],
|
||||
currentInvites: Invite[],
|
||||
rooms: Room[],
|
||||
meetId: string
|
||||
): Promise<void> {
|
||||
const client = getClient()
|
||||
const meeting = await client.findOne(love.mixin.Meeting, { _id: meetId as Ref<Meeting> })
|
||||
if (meeting === undefined) return
|
||||
const room = rooms.find((p) => p._id === meeting.room)
|
||||
const room = await client.findOne(love.class.Room, { _id: meeting.room })
|
||||
if (room === undefined) return
|
||||
|
||||
// check time (it should be 10 minutes before the meeting or active in roomInfo)
|
||||
const now = new Date()
|
||||
const res = getAllEvents([meeting], now.setMinutes(now.getMinutes() - 10), new Date().getTime())
|
||||
if (res.length === 0) {
|
||||
console.log('Meeting is not active')
|
||||
return
|
||||
}
|
||||
|
||||
await tryConnect(
|
||||
personByIdStore,
|
||||
@ -775,6 +780,7 @@ export async function createMeeting (
|
||||
const event = await client.findOne(calendar.class.Event, { _id })
|
||||
if (event === undefined) return
|
||||
const navigateUrl = getCurrentLocation()
|
||||
navigateUrl.path[2] = loveId
|
||||
navigateUrl.query = {
|
||||
meetId: _id
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user