Update static/js/12-calls.js
This commit is contained in:
parent
2baa0d8d4a
commit
746d655b73
@ -1,3 +1,4 @@
|
||||
// static/js/12-calls.js
|
||||
"use strict";
|
||||
window.Glow = window.Glow || {};
|
||||
Glow.calls = Glow.calls || {};
|
||||
@ -42,6 +43,7 @@ Glow.calls.ensureState = () => {
|
||||
state.makingOffer ||= new Map();
|
||||
state.ignoreOffer ||= new Map();
|
||||
state.isSettingRemoteAnswerPending ||= new Map();
|
||||
state.panelOpen ??= false;
|
||||
};
|
||||
|
||||
Glow.calls.scopeLabel = invite => {
|
||||
@ -581,26 +583,6 @@ Glow.calls.renderParticipants = () => {
|
||||
}
|
||||
};
|
||||
|
||||
Glow.calls.renderHeaderCallChip = () => {
|
||||
if (!Glow.els.callStatusChip) return;
|
||||
|
||||
Glow.calls.ensureState();
|
||||
const state = Glow.calls.state();
|
||||
const visible = Boolean(state.activeCall || state.joining || state.reconnecting);
|
||||
|
||||
Glow.els.callStatusChip.classList.toggle("hidden", !visible);
|
||||
|
||||
if (state.reconnecting) {
|
||||
Glow.els.callStatusChip.textContent = "Call reconnecting";
|
||||
} else if (state.joining) {
|
||||
Glow.els.callStatusChip.textContent = "Call joining";
|
||||
} else if (state.activeCall) {
|
||||
Glow.els.callStatusChip.textContent = "Call active";
|
||||
} else {
|
||||
Glow.els.callStatusChip.textContent = "Call";
|
||||
}
|
||||
};
|
||||
|
||||
Glow.calls.connectWebSocket = async () => {
|
||||
Glow.calls.ensureState();
|
||||
const state = Glow.calls.state();
|
||||
@ -910,12 +892,14 @@ Glow.calls.resetAll = () => {
|
||||
can_end: false,
|
||||
can_invite: false
|
||||
};
|
||||
state.panelOpen = false;
|
||||
|
||||
Glow.calls.debug("resetAll complete");
|
||||
};
|
||||
|
||||
Glow.endLocalCallUi = async () => {
|
||||
Glow.calls.resetAll();
|
||||
Glow.state.calls.panelOpen = false;
|
||||
|
||||
if (Glow.els.callParticipants) {
|
||||
Glow.els.callParticipants.replaceChildren();
|
||||
@ -1035,12 +1019,13 @@ Glow.renderCallUi = () => {
|
||||
|
||||
const active = Boolean(state.activeCall);
|
||||
const busy = Boolean(state.activeCall || state.joining || state.reconnecting);
|
||||
const overlayVisible = Boolean(state.panelOpen || busy);
|
||||
const scope = state.activeCall?.scope || state.scope || Glow.calls.getCurrentScope();
|
||||
const peerCount = Glow.calls.listOtherPeers().length;
|
||||
|
||||
if (!Glow.els.callStatus) return;
|
||||
|
||||
Glow.els.callOverlay?.classList.toggle("hidden", !busy);
|
||||
Glow.els.callOverlay?.classList.toggle("hidden", !overlayVisible);
|
||||
|
||||
Glow.els.callPeerLabel.textContent =
|
||||
scope?.label ||
|
||||
@ -1095,7 +1080,7 @@ Glow.renderCallUi = () => {
|
||||
}
|
||||
|
||||
if (Glow.els.callParticipants) {
|
||||
Glow.els.callParticipants.classList.toggle("hidden", !busy);
|
||||
Glow.els.callParticipants.classList.toggle("hidden", !overlayVisible);
|
||||
}
|
||||
|
||||
Glow.calls.renderParticipants();
|
||||
@ -1103,18 +1088,6 @@ Glow.renderCallUi = () => {
|
||||
Glow.calls.renderHeaderCallChip();
|
||||
};
|
||||
|
||||
Glow.openCallPanel = async () => {
|
||||
Glow.calls.ensureState();
|
||||
Glow.els.callOverlay?.classList.remove("hidden");
|
||||
Glow.els.callParticipants?.classList.remove("hidden");
|
||||
|
||||
if (Glow.state.calls.activeCall?.groupSession?.id) {
|
||||
await Glow.calls.refreshBackendParticipants();
|
||||
}
|
||||
|
||||
Glow.renderCallUi();
|
||||
};
|
||||
|
||||
Glow.startCall = async () => {
|
||||
Glow.calls.ensureState();
|
||||
|
||||
@ -1153,6 +1126,7 @@ Glow.startCall = async () => {
|
||||
Glow.state.calls.makingOffer = new Map();
|
||||
Glow.state.calls.ignoreOffer = new Map();
|
||||
Glow.state.calls.isSettingRemoteAnswerPending = new Map();
|
||||
Glow.state.calls.panelOpen = true;
|
||||
|
||||
Glow.openCallPanel();
|
||||
Glow.calls.setStatusText("Connecting microphone…");
|
||||
@ -1379,6 +1353,7 @@ Glow.calls.openIncomingInviteDialog = async invite => {
|
||||
Glow.state.calls.makingOffer = new Map();
|
||||
Glow.state.calls.ignoreOffer = new Map();
|
||||
Glow.state.calls.isSettingRemoteAnswerPending = new Map();
|
||||
Glow.state.calls.panelOpen = true;
|
||||
|
||||
Glow.openCallPanel();
|
||||
Glow.calls.setStatusText("Connecting microphone…");
|
||||
@ -1453,12 +1428,4 @@ Glow.els.endCallButton?.addEventListener("click", () => {
|
||||
|
||||
Glow.els.addToCallButton?.addEventListener("click", () => {
|
||||
Glow.openAddToCallDialog?.();
|
||||
});
|
||||
|
||||
Glow.els.closeCallPanelButton?.addEventListener("click", () => {
|
||||
Glow.els.callOverlay?.classList.add("hidden");
|
||||
});
|
||||
|
||||
Glow.els.callStatusChip?.addEventListener("click", async () => {
|
||||
await Glow.openCallPanel?.();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user