mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-02 06:42:33 -08:00
fix(call): load the call iframe after the widget transport is listening
This commit is contained in:
2 files changed
+25
-5
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('../../utils/debugLogger', () => ({
|
||||
createDebugLogger: () => ({
|
||||
info: vi.fn<(...args: unknown[]) => void>(),
|
||||
warn: vi.fn<(...args: unknown[]) => void>(),
|
||||
error: vi.fn<(...args: unknown[]) => void>(),
|
||||
debug: vi.fn<(...args: unknown[]) => void>(),
|
||||
}),
|
||||
}));
|
||||
|
||||
import { CallEmbed } from './CallEmbed';
|
||||
|
||||
describe('CallEmbed.getIframe', () => {
|
||||
it('leaves src unset so the caller can load after the transport is listening', () => {
|
||||
const iframe = CallEmbed.getIframe();
|
||||
|
||||
expect(iframe.getAttribute('src')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -194,7 +194,7 @@ export class CallEmbed {
|
||||
return widget;
|
||||
}
|
||||
|
||||
static getIframe(url: string): HTMLIFrameElement {
|
||||
static getIframe(): HTMLIFrameElement {
|
||||
const iframe = document.createElement('iframe');
|
||||
|
||||
iframe.title = 'Call Embed';
|
||||
@@ -202,7 +202,6 @@ export class CallEmbed {
|
||||
'allow-forms allow-scripts allow-same-origin allow-popups allow-modals allow-downloads';
|
||||
iframe.allow =
|
||||
'microphone; camera; display-capture; autoplay; clipboard-write; local-network-access;';
|
||||
iframe.src = url;
|
||||
|
||||
iframe.style.width = '100%';
|
||||
iframe.style.height = '100%';
|
||||
@@ -220,14 +219,15 @@ export class CallEmbed {
|
||||
) {
|
||||
debugLog.info('call', 'Initializing call embed', { roomId: room.roomId });
|
||||
|
||||
const iframe = CallEmbed.getIframe(
|
||||
widget.getCompleteUrl({ currentUserId: mx.getSafeUserId() })
|
||||
);
|
||||
const iframe = CallEmbed.getIframe();
|
||||
container.append(iframe);
|
||||
|
||||
const callWidgetDriver: WidgetDriver = new CallWidgetDriver(mx, room.roomId);
|
||||
const call: ClientWidgetApi = new ClientWidgetApi(widget, iframe, callWidgetDriver);
|
||||
|
||||
// Load after the transport is listening, or a fast iframe's contentLoaded is missed.
|
||||
iframe.src = widget.getCompleteUrl({ currentUserId: mx.getSafeUserId() });
|
||||
|
||||
this.mx = mx;
|
||||
this.call = call;
|
||||
this.room = room;
|
||||
|
||||
Reference in new issue
Block a user