mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-12 19:30:52 +00:00
Meeting fixes (#7218)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
1 Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
500a221ceb
commit
1b415d6a6f
@ -45,8 +45,10 @@
|
||||
dispatch('open', { ignoreKeys: ['name'] })
|
||||
})
|
||||
|
||||
let tryConnecting = false
|
||||
|
||||
async function connect (): Promise<void> {
|
||||
connecting = true
|
||||
tryConnecting = true
|
||||
const place = $selectedRoomPlace
|
||||
await tryConnect(
|
||||
$personByIdStore,
|
||||
@ -57,11 +59,11 @@
|
||||
$invites,
|
||||
place?._id === object._id ? { x: place.x, y: place.y } : undefined
|
||||
)
|
||||
connecting = false
|
||||
tryConnecting = false
|
||||
selectedRoomPlace.set(undefined)
|
||||
}
|
||||
|
||||
$: connecting = connecting || ($currentRoom?._id === object._id && !$isConnected)
|
||||
$: connecting = tryConnecting || ($currentRoom?._id === object._id && !$isConnected)
|
||||
|
||||
let connectLabel: IntlString = $infos.some(({ room }) => room === object._id)
|
||||
? love.string.JoinMeeting
|
||||
@ -72,6 +74,17 @@
|
||||
} else if (!connecting) {
|
||||
connectLabel = love.string.StartMeeting
|
||||
}
|
||||
|
||||
function showConnectionButton (object: Room, isConnected: boolean, myOffice?: Room, currentRoom?: Room): boolean {
|
||||
// Do not show connect button in my office
|
||||
if (object._id === myOffice?._id) return false
|
||||
// Show during connecting with spinner
|
||||
if (connecting) return true
|
||||
// Do not show connect button if we are already connected to the room
|
||||
if (isConnected && currentRoom?._id === object._id) return false
|
||||
|
||||
return true
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex-row-stretch">
|
||||
@ -85,7 +98,7 @@
|
||||
focusIndex={1}
|
||||
/>
|
||||
</div>
|
||||
{#if object._id !== $myOffice?._id && ($currentRoom?._id !== object._id || connecting)}
|
||||
{#if showConnectionButton(object, $isConnected, $myOffice, $currentRoom)}
|
||||
<ModernButton label={connectLabel} size="large" kind={'primary'} on:click={connect} loading={connecting} />
|
||||
{/if}
|
||||
</div>
|
||||
|
@ -16,16 +16,15 @@
|
||||
import { Person, type PersonAccount } from '@hcengineering/contact'
|
||||
import { Avatar, personByIdStore } from '@hcengineering/contact-resources'
|
||||
import { IdMap, getCurrentAccount } from '@hcengineering/core'
|
||||
import { isOffice, ParticipantInfo, Room, RoomAccess, RoomType } from '@hcengineering/love'
|
||||
import { isOffice, ParticipantInfo, Room, RoomAccess, RoomType, MeetingStatus } from '@hcengineering/love'
|
||||
import { Icon, Label, eventToHTMLElement, showPopup } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { openDoc } from '@hcengineering/view-resources'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
import love from '../plugin'
|
||||
import { myInfo, selectedRoomPlace, currentRoom, currentMeetingMinutes } from '../stores'
|
||||
import { getRoomLabel, lk } from '../utils'
|
||||
import { getRoomLabel, lk, isConnected } from '../utils'
|
||||
import PersonActionPopup from './PersonActionPopup.svelte'
|
||||
import RoomLanguage from './RoomLanguage.svelte'
|
||||
|
||||
@ -67,14 +66,20 @@
|
||||
async function openRoom (x: number, y: number): Promise<void> {
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
if ($currentRoom?._id === room._id) {
|
||||
if ($isConnected && $currentRoom?._id === room._id) {
|
||||
const sid = await lk.getSid()
|
||||
const meetingMinutes =
|
||||
get(currentMeetingMinutes) ?? (await client.findOne(love.class.MeetingMinutes, { sid, attachedTo: room._id }))
|
||||
if (meetingMinutes === undefined) {
|
||||
let meeting = $currentMeetingMinutes
|
||||
if (meeting?.sid !== sid || meeting?.attachedTo !== room._id || meeting?.status !== MeetingStatus.Active) {
|
||||
meeting = await client.findOne(love.class.MeetingMinutes, {
|
||||
sid,
|
||||
attachedTo: room._id,
|
||||
status: MeetingStatus.Active
|
||||
})
|
||||
}
|
||||
if (meeting === undefined) {
|
||||
await openDoc(hierarchy, room)
|
||||
} else {
|
||||
await openDoc(hierarchy, meetingMinutes)
|
||||
await openDoc(hierarchy, meeting)
|
||||
}
|
||||
} else {
|
||||
selectedRoomPlace.set({ _id: room._id, x, y })
|
||||
|
@ -15,13 +15,13 @@
|
||||
<script lang="ts">
|
||||
import { closeWidget, minimizeSidebar, WidgetState } from '@hcengineering/workbench-resources'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { MeetingMinutes, Room } from '@hcengineering/love'
|
||||
import { MeetingMinutes, MeetingStatus, Room } from '@hcengineering/love'
|
||||
import { Loading } from '@hcengineering/ui'
|
||||
|
||||
import love from '../../plugin'
|
||||
import VideoTab from './VideoTab.svelte'
|
||||
import { isCurrentInstanceConnected, lk } from '../../utils'
|
||||
import { currentRoom, currentMeetingMinutes } from '../../stores'
|
||||
import { currentMeetingMinutes, currentRoom } from '../../stores'
|
||||
import ChatTab from './ChatTab.svelte'
|
||||
import TranscriptionTab from './TranscriptionTab.svelte'
|
||||
|
||||
@ -58,13 +58,17 @@
|
||||
}
|
||||
|
||||
$: if (sid != null && room !== undefined) {
|
||||
meetingQuery.query(love.class.MeetingMinutes, { sid, attachedTo: room._id }, async (res) => {
|
||||
meetingMinutes = res[0]
|
||||
if (meetingMinutes) {
|
||||
currentMeetingMinutes.set(meetingMinutes)
|
||||
meetingQuery.query(
|
||||
love.class.MeetingMinutes,
|
||||
{ sid, attachedTo: room._id, status: MeetingStatus.Active },
|
||||
async (res) => {
|
||||
meetingMinutes = res[0]
|
||||
if (meetingMinutes) {
|
||||
currentMeetingMinutes.set(meetingMinutes)
|
||||
}
|
||||
isMeetingMinutesLoaded = true
|
||||
}
|
||||
isMeetingMinutesLoaded = true
|
||||
})
|
||||
)
|
||||
} else {
|
||||
meetingQuery.unsubscribe()
|
||||
meetingMinutes = undefined
|
||||
|
@ -85,7 +85,7 @@ import { getObjectLinkFragment } from '@hcengineering/view-resources'
|
||||
|
||||
import { sendMessage } from './broadcast'
|
||||
import love from './plugin'
|
||||
import { $myPreferences, currentRoom, currentMeetingMinutes, selectedRoomPlace } from './stores'
|
||||
import { $myPreferences, currentRoom, currentMeetingMinutes, selectedRoomPlace, myOffice } from './stores'
|
||||
import RoomSettingsPopup from './components/RoomSettingsPopup.svelte'
|
||||
|
||||
export const selectedCamId = 'selectedDevice_cam'
|
||||
@ -427,18 +427,32 @@ function initRoomMetadata (metadata: string | undefined): void {
|
||||
void record(room)
|
||||
}
|
||||
}
|
||||
export async function connect (name: string, room: Room, _id: string): Promise<void> {
|
||||
|
||||
async function withRetries (fn: () => Promise<void>, retries: number, delay: number): Promise<void> {
|
||||
for (let attempt = 0; attempt < retries; attempt++) {
|
||||
try {
|
||||
await fn()
|
||||
return
|
||||
} catch (error) {
|
||||
if (attempt >= retries) {
|
||||
throw error
|
||||
}
|
||||
console.error(error)
|
||||
console.log(`Attempt ${attempt} failed. Retrying in ${delay}ms...`)
|
||||
await new Promise((resolve) => setTimeout(resolve, delay))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function connect (name: string, room: Room, _id: string): Promise<void> {
|
||||
const wsURL = getMetadata(love.metadata.WebSocketURL)
|
||||
if (wsURL === undefined) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const token = await getToken(room.name, room._id, _id, name)
|
||||
await lk.connect(wsURL, token)
|
||||
sendMessage({ type: 'connect', value: true })
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
const token = await getToken(room.name, room._id, _id, name)
|
||||
await lk.connect(wsURL, token)
|
||||
sendMessage({ type: 'connect', value: true })
|
||||
}
|
||||
|
||||
export async function awaitConnect (): Promise<void> {
|
||||
@ -647,7 +661,11 @@ async function navigateToOfficeDoc (hierarchy: Hierarchy, object: Doc): Promise<
|
||||
async function openMeetingMinutes (room: Room): Promise<void> {
|
||||
const client = getClient()
|
||||
const sid = await lk.getSid()
|
||||
const doc = await client.findOne(love.class.MeetingMinutes, { sid })
|
||||
const doc = await client.findOne(love.class.MeetingMinutes, {
|
||||
sid,
|
||||
attachedTo: room._id,
|
||||
status: MeetingStatus.Active
|
||||
})
|
||||
|
||||
if (doc === undefined) {
|
||||
const date = new Date()
|
||||
@ -696,9 +714,6 @@ async function openMeetingMinutes (room: Room): Promise<void> {
|
||||
if (loc.path[2] === loveId || room.type === RoomType.Video) {
|
||||
await navigateToOfficeDoc(client.getHierarchy(), doc)
|
||||
}
|
||||
if (doc.status !== MeetingStatus.Active) {
|
||||
void client.update(doc, { status: MeetingStatus.Active, meetingEnd: undefined })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -711,9 +726,20 @@ export async function connectRoom (
|
||||
): Promise<void> {
|
||||
await disconnect()
|
||||
await moveToRoom(x, y, currentInfo, currentPerson, room, getMetadata(presentation.metadata.SessionId) ?? null)
|
||||
await connectLK(currentPerson, room)
|
||||
selectedRoomPlace.set(undefined)
|
||||
await openMeetingMinutes(room)
|
||||
try {
|
||||
await withRetries(
|
||||
async () => {
|
||||
await connectLK(currentPerson, room)
|
||||
},
|
||||
3,
|
||||
1000
|
||||
)
|
||||
await openMeetingMinutes(room)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
await leaveRoom(currentInfo, get(myOffice))
|
||||
}
|
||||
}
|
||||
|
||||
export const joinRequest: Ref<JoinRequest> | undefined = undefined
|
||||
|
@ -16,6 +16,7 @@ import core, {
|
||||
import love, {
|
||||
getFreeRoomPlace,
|
||||
MeetingMinutes,
|
||||
MeetingStatus,
|
||||
ParticipantInfo,
|
||||
Room,
|
||||
RoomLanguage,
|
||||
@ -216,7 +217,9 @@ export class LoveController {
|
||||
if (sid === '') return undefined
|
||||
|
||||
const doc =
|
||||
this.meetingMinutes.find((m) => m.sid === sid) ?? (await this.client.findOne(love.class.MeetingMinutes, { sid }))
|
||||
this.meetingMinutes.find(
|
||||
(m) => m.sid === sid && m.attachedTo === room._id && m.status === MeetingStatus.Active
|
||||
) ?? (await this.client.findOne(love.class.MeetingMinutes, { sid, room: room._id, status: MeetingStatus.Active }))
|
||||
|
||||
if (doc === undefined) {
|
||||
return undefined
|
||||
|
Loading…
Reference in New Issue
Block a user