From 1b415d6a6f751f6685db6bf3ca962f9baef5d820 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 21 Nov 2024 22:34:31 +0400 Subject: [PATCH] Meeting fixes (#7218) 1 Signed-off-by: Kristina Fefelova --- .../src/components/EditRoom.svelte | 21 +++++-- .../src/components/RoomPreview.svelte | 21 ++++--- .../components/widget/MeetingWidget.svelte | 20 ++++--- plugins/love-resources/src/utils.ts | 56 ++++++++++++++----- .../ai-bot/pod-ai-bot/src/workspace/love.ts | 5 +- 5 files changed, 87 insertions(+), 36 deletions(-) diff --git a/plugins/love-resources/src/components/EditRoom.svelte b/plugins/love-resources/src/components/EditRoom.svelte index 8dbdc824b8..4a5d3a0304 100644 --- a/plugins/love-resources/src/components/EditRoom.svelte +++ b/plugins/love-resources/src/components/EditRoom.svelte @@ -45,8 +45,10 @@ dispatch('open', { ignoreKeys: ['name'] }) }) + let tryConnecting = false + async function connect (): Promise { - 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 + }
@@ -85,7 +98,7 @@ focusIndex={1} />
- {#if object._id !== $myOffice?._id && ($currentRoom?._id !== object._id || connecting)} + {#if showConnectionButton(object, $isConnected, $myOffice, $currentRoom)} {/if} diff --git a/plugins/love-resources/src/components/RoomPreview.svelte b/plugins/love-resources/src/components/RoomPreview.svelte index a1783be146..4a5fd4297e 100644 --- a/plugins/love-resources/src/components/RoomPreview.svelte +++ b/plugins/love-resources/src/components/RoomPreview.svelte @@ -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 { 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 }) diff --git a/plugins/love-resources/src/components/widget/MeetingWidget.svelte b/plugins/love-resources/src/components/widget/MeetingWidget.svelte index 91b854c640..efb67682a8 100644 --- a/plugins/love-resources/src/components/widget/MeetingWidget.svelte +++ b/plugins/love-resources/src/components/widget/MeetingWidget.svelte @@ -15,13 +15,13 @@