diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index 61a81a3fe7..4ef6fb44a8 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -534,17 +534,17 @@ export async function getBlobURL (blob: Blob): Promise { /** * @public */ -export async function copyTextToClipboard (text: string): Promise { +export async function copyTextToClipboard (text: string | Promise): Promise { try { // Safari specific behavior // see https://bugs.webkit.org/show_bug.cgi?id=222262 const clipboardItem = new ClipboardItem({ - 'text/plain': Promise.resolve(text) + 'text/plain': text instanceof Promise ? text : Promise.resolve(text) }) await navigator.clipboard.write([clipboardItem]) } catch { // Fallback to default clipboard API implementation - await navigator.clipboard.writeText(text) + await navigator.clipboard.writeText(text instanceof Promise ? await text : text) } } diff --git a/plugins/login-resources/src/components/Join.svelte b/plugins/login-resources/src/components/Join.svelte index 43a4a50d1e..902325ee63 100644 --- a/plugins/login-resources/src/components/Join.svelte +++ b/plugins/login-resources/src/components/Join.svelte @@ -14,7 +14,13 @@ --> diff --git a/plugins/love-resources/src/components/RoomPreview.svelte b/plugins/love-resources/src/components/RoomPreview.svelte index 4666cf6512..2a6b516705 100644 --- a/plugins/love-resources/src/components/RoomPreview.svelte +++ b/plugins/love-resources/src/components/RoomPreview.svelte @@ -17,7 +17,7 @@ import { Avatar, personByIdStore } from '@hcengineering/contact-resources' import { IdMap, getCurrentAccount } from '@hcengineering/core' import { ParticipantInfo, Room, RoomAccess, RoomType } from '@hcengineering/love' - import { Icon, Label, eventToHTMLElement, showPopup, showTooltip } from '@hcengineering/ui' + import { Icon, Label, eventToHTMLElement, showPopup } from '@hcengineering/ui' import { createEventDispatcher } from 'svelte' import love from '../plugin' import { invites, myInfo, myRequests } from '../stores' diff --git a/plugins/love-resources/src/utils.ts b/plugins/love-resources/src/utils.ts index 8593048ca5..d2dce4af16 100644 --- a/plugins/love-resources/src/utils.ts +++ b/plugins/love-resources/src/utils.ts @@ -1,11 +1,6 @@ import { Analytics } from '@hcengineering/analytics' import contact, { getName, type Person, type PersonAccount } from '@hcengineering/contact' import core, { concatLink, getCurrentAccount, type IdMap, type Ref, type Space } from '@hcengineering/core' -import { getEmbeddedLabel, getMetadata, type IntlString } from '@hcengineering/platform' -import presentation, { createQuery, getClient } from '@hcengineering/presentation' -import { getCurrentLocation, navigate, type DropdownTextItem } from '@hcengineering/ui' -import { KrispNoiseFilter, isKrispNoiseFilterSupported } from '@livekit/krisp-noise-filter' -import { BackgroundBlur, type BackgroundOptions, type ProcessorWrapper } from '@livekit/track-processors' import { RequestStatus, RoomAccess, @@ -18,15 +13,20 @@ import { type ParticipantInfo, type Room } from '@hcengineering/love' +import { getEmbeddedLabel, getMetadata, type IntlString } from '@hcengineering/platform' +import presentation, { createQuery, getClient } from '@hcengineering/presentation' +import { getCurrentLocation, navigate, type DropdownTextItem } from '@hcengineering/ui' +import { KrispNoiseFilter, isKrispNoiseFilterSupported } from '@livekit/krisp-noise-filter' +import { BackgroundBlur, type BackgroundOptions, type ProcessorWrapper } from '@livekit/track-processors' import { ConnectionState, Room as LKRoom, LocalAudioTrack, - type LocalTrack, LocalVideoTrack, RoomEvent, Track, type AudioCaptureOptions, + type LocalTrack, type LocalTrackPublication, type RemoteParticipant, type RemoteTrack, @@ -568,7 +568,10 @@ export async function tryConnect ( const currentPerson = personByIdStore.get((me as PersonAccount).person) if (currentPerson === undefined) return const client = getClient() + + // guests can't join without invite if (!client.getHierarchy().hasMixin(currentPerson, contact.mixin.Employee)) return + if (room._id === currentInfo?.room) return if (room.access === RoomAccess.DND) return const thisRoomRequest = currentRequests.find((p) => p.room === room._id) diff --git a/server-plugins/love-resources/src/index.ts b/server-plugins/love-resources/src/index.ts index d86f7a284e..8c963c56ad 100644 --- a/server-plugins/love-resources/src/index.ts +++ b/server-plugins/love-resources/src/index.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import contact, { Employee, Person, PersonAccount, getName, formatName } from '@hcengineering/contact' +import contact, { Employee, Person, PersonAccount, formatName, getName } from '@hcengineering/contact' import core, { Account, Ref, @@ -25,7 +25,6 @@ import core, { TxUpdateDoc, UserStatus } from '@hcengineering/core' -import { TriggerControl } from '@hcengineering/server-core' import love, { Invite, JoinRequest, @@ -36,10 +35,11 @@ import love, { isOffice, loveId } from '@hcengineering/love' -import { createPushNotification, isAllowed } from '@hcengineering/server-notification-resources' import notification from '@hcengineering/notification' -import { workbenchId } from '@hcengineering/workbench' import { translate } from '@hcengineering/platform' +import { TriggerControl } from '@hcengineering/server-core' +import { createPushNotification, isAllowed } from '@hcengineering/server-notification-resources' +import { workbenchId } from '@hcengineering/workbench' export async function OnEmployee (tx: Tx, control: TriggerControl): Promise { const actualTx = TxProcessor.extractTx(tx) as TxMixin @@ -202,11 +202,15 @@ function setDefaultRoomAccess (info: ParticipantInfo, roomInfos: RoomInfo[], con const oldRoomInfo = roomInfos.find((ri) => ri.persons.includes(info.person)) if (oldRoomInfo !== undefined) { oldRoomInfo.persons = oldRoomInfo.persons.filter((p) => p !== info.person) - res.push( - control.txFactory.createTxUpdateDoc(love.class.RoomInfo, core.space.Workspace, oldRoomInfo._id, { - persons: oldRoomInfo.persons - }) - ) + if (oldRoomInfo.persons.length === 0) { + res.push(control.txFactory.createTxRemoveDoc(oldRoomInfo._class, oldRoomInfo.space, oldRoomInfo._id)) + } else { + res.push( + control.txFactory.createTxUpdateDoc(love.class.RoomInfo, core.space.Workspace, oldRoomInfo._id, { + persons: oldRoomInfo.persons + }) + ) + } if (oldRoomInfo.persons.length === 0) { const resetAccessTx = control.txFactory.createTxUpdateDoc( oldRoomInfo.isOffice ? love.class.Office : love.class.Room,