2024-02-13 02:08:24 +01:00
|
|
|
import {realm} from "./state_data";
|
2023-10-04 02:37:28 +02:00
|
|
|
|
|
|
|
export const zoom_token_callbacks = new Map();
|
2024-05-02 23:42:35 +02:00
|
|
|
export const video_call_xhrs = new Map<string, JQuery.jqXHR<unknown>>();
|
2023-10-04 02:37:28 +02:00
|
|
|
|
2023-10-11 00:56:16 +02:00
|
|
|
export function get_jitsi_server_url(): string | null {
|
2024-02-13 02:08:24 +01:00
|
|
|
return realm.realm_jitsi_server_url ?? realm.server_jitsi_server_url;
|
2023-10-04 02:37:28 +02:00
|
|
|
}
|
|
|
|
|
2023-10-11 00:56:16 +02:00
|
|
|
export function abort_video_callbacks(edit_message_id = ""): void {
|
2023-10-04 02:37:28 +02:00
|
|
|
zoom_token_callbacks.delete(edit_message_id);
|
2024-05-02 23:42:35 +02:00
|
|
|
const xhr = video_call_xhrs.get(edit_message_id);
|
|
|
|
if (xhr !== undefined) {
|
|
|
|
xhr.abort();
|
2023-10-04 02:37:28 +02:00
|
|
|
video_call_xhrs.delete(edit_message_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-11 00:56:16 +02:00
|
|
|
export function compute_show_video_chat_button(): boolean {
|
2024-02-13 02:08:24 +01:00
|
|
|
const available_providers = realm.realm_available_video_chat_providers;
|
|
|
|
if (realm.realm_video_chat_provider === available_providers.disabled.id) {
|
2023-10-04 02:37:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
2024-02-13 02:08:24 +01:00
|
|
|
realm.realm_video_chat_provider === available_providers.jitsi_meet.id &&
|
2023-10-04 02:37:28 +02:00
|
|
|
!get_jitsi_server_url()
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-10-11 00:56:16 +02:00
|
|
|
export function compute_show_audio_chat_button(): boolean {
|
2024-02-13 02:08:24 +01:00
|
|
|
const available_providers = realm.realm_available_video_chat_providers;
|
2023-10-04 02:37:28 +02:00
|
|
|
if (
|
|
|
|
(available_providers.jitsi_meet &&
|
2023-12-22 01:46:30 +01:00
|
|
|
get_jitsi_server_url() !== null &&
|
2024-02-13 02:08:24 +01:00
|
|
|
realm.realm_video_chat_provider === available_providers.jitsi_meet.id) ||
|
2023-10-04 02:37:28 +02:00
|
|
|
(available_providers.zoom &&
|
2024-02-13 02:08:24 +01:00
|
|
|
realm.realm_video_chat_provider === available_providers.zoom.id)
|
2023-10-04 02:37:28 +02:00
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|