mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
Fix double meeting initialization (#7256)
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
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
6af28c9655
commit
6d31873779
@ -75,7 +75,13 @@
|
||||
connectLabel = love.string.StartMeeting
|
||||
}
|
||||
|
||||
function showConnectionButton (object: Room, isConnected: boolean, myOffice?: Room, currentRoom?: Room): boolean {
|
||||
function showConnectionButton (
|
||||
object: Room,
|
||||
connecting: boolean,
|
||||
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
|
||||
@ -98,7 +104,7 @@
|
||||
focusIndex={1}
|
||||
/>
|
||||
</div>
|
||||
{#if showConnectionButton(object, $isConnected, $myOffice, $currentRoom)}
|
||||
{#if showConnectionButton(object, connecting, $isConnected, $myOffice, $currentRoom)}
|
||||
<ModernButton label={connectLabel} size="large" kind={'primary'} on:click={connect} loading={connecting} />
|
||||
{/if}
|
||||
</div>
|
||||
|
@ -374,16 +374,12 @@ lk.on(RoomEvent.RecordingStatusChanged, (evt) => {
|
||||
isRecording.set(evt)
|
||||
})
|
||||
lk.on(RoomEvent.RoomMetadataChanged, (metadata) => {
|
||||
try {
|
||||
const data = JSON.parse(metadata) as RoomMetadata
|
||||
if (data.recording !== undefined) {
|
||||
isRecording.set(data.recording)
|
||||
}
|
||||
if (data.transcription !== undefined) {
|
||||
isTranscription.set(data.transcription === TranscriptionStatus.InProgress)
|
||||
}
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
const data = parseMetadata(metadata)
|
||||
if (data.recording !== undefined) {
|
||||
isRecording.set(data.recording)
|
||||
}
|
||||
if (data.transcription !== undefined) {
|
||||
isTranscription.set(data.transcription === TranscriptionStatus.InProgress)
|
||||
}
|
||||
})
|
||||
|
||||
@ -392,7 +388,7 @@ lk.on(RoomEvent.Connected, () => {
|
||||
sendMessage({ type: 'connect', value: true })
|
||||
isCurrentInstanceConnected.set(true)
|
||||
isRecording.set(lk.isRecording)
|
||||
void initRoomMetadata(lk.metadata)
|
||||
void initRoom()
|
||||
Analytics.handleEvent(LoveEvents.ConnectedToRoom)
|
||||
})
|
||||
lk.on(RoomEvent.Disconnected, () => {
|
||||
@ -402,25 +398,19 @@ lk.on(RoomEvent.Disconnected, () => {
|
||||
Analytics.handleEvent(LoveEvents.DisconnectedFromRoom)
|
||||
})
|
||||
|
||||
async function initRoomMetadata (metadata: string | undefined): Promise<void> {
|
||||
let data: RoomMetadata
|
||||
try {
|
||||
data = metadata == null || metadata === '' ? {} : JSON.parse(metadata)
|
||||
} catch (err: any) {
|
||||
data = {}
|
||||
Analytics.handleError(err)
|
||||
}
|
||||
|
||||
isTranscription.set(data.transcription === TranscriptionStatus.InProgress)
|
||||
|
||||
async function initRoom (): Promise<void> {
|
||||
const room = get(currentRoom)
|
||||
const meetingMinutes = get(currentMeetingMinutes)
|
||||
const isValidMeeting =
|
||||
meetingMinutes != null && meetingMinutes.attachedTo === room?._id && meetingMinutes.status === MeetingStatus.Active
|
||||
|
||||
if (room != null && !isValidMeeting) {
|
||||
if (room !== undefined) {
|
||||
await initMeetingMinutes(room)
|
||||
}
|
||||
await initRoomMetadata(lk.metadata)
|
||||
}
|
||||
|
||||
async function initRoomMetadata (metadata: string | undefined): Promise<void> {
|
||||
const room = get(currentRoom)
|
||||
const data: RoomMetadata = parseMetadata(metadata)
|
||||
|
||||
isTranscription.set(data.transcription === TranscriptionStatus.InProgress)
|
||||
|
||||
if (
|
||||
(data.transcription == null || data.transcription === TranscriptionStatus.Idle) &&
|
||||
@ -434,6 +424,15 @@ async function initRoomMetadata (metadata: string | undefined): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function parseMetadata (metadata: string | undefined): RoomMetadata {
|
||||
try {
|
||||
return metadata == null || metadata === '' ? {} : JSON.parse(metadata)
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
async function withRetries (fn: () => Promise<void>, retries: number, delay: number): Promise<void> {
|
||||
for (let attempt = 0; attempt < retries; attempt++) {
|
||||
try {
|
||||
@ -738,7 +737,6 @@ export async function connectRoom (
|
||||
3,
|
||||
1000
|
||||
)
|
||||
await initMeetingMinutes(room)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
await leaveRoom(currentInfo, get(myOffice))
|
||||
|
Loading…
Reference in New Issue
Block a user