@poolse/react 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +49 -1
- package/dist/index.cjs +2340 -157
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +758 -3
- package/dist/index.d.ts +758 -3
- package/dist/index.js +2057 -112
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -630,6 +630,9 @@ function useMembers(conversationId) {
|
|
|
630
630
|
const [error, setError] = react.useState(null);
|
|
631
631
|
const membersRef = react.useRef([]);
|
|
632
632
|
membersRef.current = members;
|
|
633
|
+
react.useEffect(() => {
|
|
634
|
+
chat.users.noteAgents(members);
|
|
635
|
+
}, [chat, members]);
|
|
633
636
|
const pendingReadsRef = react.useRef([]);
|
|
634
637
|
const hasFetchedRef = react.useRef(false);
|
|
635
638
|
const applyRead = (list, evt) => list.map(
|
|
@@ -747,6 +750,9 @@ function useMessages(conversationId) {
|
|
|
747
750
|
if (loading) return;
|
|
748
751
|
chat.cache.setMessages(conversationId, messages);
|
|
749
752
|
}, [chat, conversationId, messages, loading]);
|
|
753
|
+
react.useEffect(() => {
|
|
754
|
+
chat.users.noteAgents(messages);
|
|
755
|
+
}, [chat, messages]);
|
|
750
756
|
react.useEffect(() => {
|
|
751
757
|
let cancelled = false;
|
|
752
758
|
let fresh = false;
|
|
@@ -1169,6 +1175,9 @@ var PAGE_SIZE2 = 500;
|
|
|
1169
1175
|
function useThread(conversationId, rootMessageId) {
|
|
1170
1176
|
const chat = usePoolse();
|
|
1171
1177
|
const [replies, setReplies] = react.useState([]);
|
|
1178
|
+
react.useEffect(() => {
|
|
1179
|
+
chat.users.noteAgents(replies);
|
|
1180
|
+
}, [chat, replies]);
|
|
1172
1181
|
const [loading, setLoading] = react.useState(true);
|
|
1173
1182
|
const [error, setError] = react.useState(null);
|
|
1174
1183
|
const [hasMore, setHasMore] = react.useState(true);
|
|
@@ -1676,15 +1685,17 @@ function useAttachmentUrl(attachmentId) {
|
|
|
1676
1685
|
}, [chat, attachmentId]);
|
|
1677
1686
|
return { url, loading, error };
|
|
1678
1687
|
}
|
|
1679
|
-
var EMPTY = { profile: null, loading: false };
|
|
1688
|
+
var EMPTY = { profile: null, loading: false, agent: null };
|
|
1680
1689
|
function useUser(externalId) {
|
|
1681
1690
|
const chat = usePoolse();
|
|
1682
1691
|
const shownForRef = react.useRef(null);
|
|
1692
|
+
const agentRef = react.useRef(null);
|
|
1683
1693
|
const [state, setState] = react.useState(() => {
|
|
1684
1694
|
if (!externalId) return EMPTY;
|
|
1685
1695
|
const cached = chat.users.peek(externalId);
|
|
1686
|
-
|
|
1687
|
-
return { profile:
|
|
1696
|
+
const agent = chat.users.agentOf(externalId);
|
|
1697
|
+
if (cached === void 0) return { profile: null, loading: true, agent };
|
|
1698
|
+
return { profile: cached, loading: false, agent };
|
|
1688
1699
|
});
|
|
1689
1700
|
react.useEffect(() => {
|
|
1690
1701
|
if (!externalId) {
|
|
@@ -1693,13 +1704,15 @@ function useUser(externalId) {
|
|
|
1693
1704
|
}
|
|
1694
1705
|
const apply = () => {
|
|
1695
1706
|
const cached = chat.users.peek(externalId);
|
|
1707
|
+
const agent = sameAgent(agentRef.current, chat.users.agentOf(externalId));
|
|
1708
|
+
agentRef.current = agent;
|
|
1696
1709
|
if (cached === void 0) {
|
|
1697
1710
|
const keep = shownForRef.current === externalId;
|
|
1698
|
-
setState((prev) => ({ profile: keep ? prev.profile : null, loading: true }));
|
|
1711
|
+
setState((prev) => ({ profile: keep ? prev.profile : null, loading: true, agent }));
|
|
1699
1712
|
void chat.users.get(externalId);
|
|
1700
1713
|
} else {
|
|
1701
1714
|
shownForRef.current = externalId;
|
|
1702
|
-
setState({ profile: cached, loading: false });
|
|
1715
|
+
setState({ profile: cached, loading: false, agent });
|
|
1703
1716
|
}
|
|
1704
1717
|
};
|
|
1705
1718
|
const off = chat.users.subscribe(externalId, apply);
|
|
@@ -1708,12 +1721,251 @@ function useUser(externalId) {
|
|
|
1708
1721
|
}, [chat, externalId]);
|
|
1709
1722
|
return state;
|
|
1710
1723
|
}
|
|
1724
|
+
function sameAgent(prev, next) {
|
|
1725
|
+
if (prev && next && prev.id === next.id && prev.name === next.name && prev.kind === next.kind) {
|
|
1726
|
+
return prev;
|
|
1727
|
+
}
|
|
1728
|
+
return next;
|
|
1729
|
+
}
|
|
1730
|
+
function useAgent(externalId) {
|
|
1731
|
+
const chat = usePoolse();
|
|
1732
|
+
const [agent, setAgent] = react.useState(() => chat.users.agentOf(externalId));
|
|
1733
|
+
react.useEffect(() => {
|
|
1734
|
+
if (!externalId) {
|
|
1735
|
+
setAgent(null);
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
const read = () => setAgent((prev) => sameAgent(prev, chat.users.agentOf(externalId)));
|
|
1739
|
+
read();
|
|
1740
|
+
return chat.users.subscribe(externalId, read);
|
|
1741
|
+
}, [chat, externalId]);
|
|
1742
|
+
return agent;
|
|
1743
|
+
}
|
|
1711
1744
|
function useAppEvent(handler) {
|
|
1712
1745
|
const chat = usePoolse();
|
|
1713
1746
|
const handlerRef = react.useRef(handler);
|
|
1714
1747
|
handlerRef.current = handler;
|
|
1715
1748
|
react.useEffect(() => chat.onAppEvent((evt) => handlerRef.current(evt)), [chat]);
|
|
1716
1749
|
}
|
|
1750
|
+
|
|
1751
|
+
// src/composer-tools.ts
|
|
1752
|
+
var FORMAT_ACTIONS = [
|
|
1753
|
+
{ kind: "bold", label: "Bold", glyph: "B", shortcut: "Mod+B" },
|
|
1754
|
+
{ kind: "italic", label: "Italic", glyph: "I", shortcut: "Mod+I" },
|
|
1755
|
+
{ kind: "strike", label: "Strikethrough", glyph: "S", shortcut: "Mod+Shift+X" },
|
|
1756
|
+
{ kind: "code", label: "Code", glyph: "<>", shortcut: "Mod+E" },
|
|
1757
|
+
{ kind: "link", label: "Link", glyph: "\u{1F517}", shortcut: "Mod+K" },
|
|
1758
|
+
{ kind: "quote", label: "Quote", glyph: "\u275D" },
|
|
1759
|
+
{ kind: "bulletList", label: "Bulleted list", glyph: "\u2022" },
|
|
1760
|
+
{ kind: "numberedList", label: "Numbered list", glyph: "1." },
|
|
1761
|
+
{ kind: "checklist", label: "Checklist", glyph: "\u2610" },
|
|
1762
|
+
{ kind: "codeBlock", label: "Code block", glyph: "{}" },
|
|
1763
|
+
{ kind: "table", label: "Table", glyph: "\u25A6" }
|
|
1764
|
+
];
|
|
1765
|
+
var INLINE = {
|
|
1766
|
+
bold: "**",
|
|
1767
|
+
italic: "_",
|
|
1768
|
+
strike: "~~",
|
|
1769
|
+
code: "`"
|
|
1770
|
+
};
|
|
1771
|
+
var LINE_PREFIX = {
|
|
1772
|
+
quote: "> ",
|
|
1773
|
+
bulletList: "- ",
|
|
1774
|
+
checklist: "- [ ] "
|
|
1775
|
+
};
|
|
1776
|
+
function clampSelection(value, sel) {
|
|
1777
|
+
const start = Math.max(0, Math.min(sel.start, sel.end, value.length));
|
|
1778
|
+
const end = Math.max(start, Math.min(Math.max(sel.start, sel.end), value.length));
|
|
1779
|
+
return { start, end };
|
|
1780
|
+
}
|
|
1781
|
+
function applyFormat(value, selection, kind) {
|
|
1782
|
+
const { start, end } = clampSelection(value, selection);
|
|
1783
|
+
const selected = value.slice(start, end);
|
|
1784
|
+
const before = value.slice(0, start);
|
|
1785
|
+
const after = value.slice(end);
|
|
1786
|
+
const marker = INLINE[kind];
|
|
1787
|
+
if (marker) {
|
|
1788
|
+
const m = marker.length;
|
|
1789
|
+
if (before.endsWith(marker) && after.startsWith(marker)) {
|
|
1790
|
+
return {
|
|
1791
|
+
value: before.slice(0, -m) + selected + after.slice(m),
|
|
1792
|
+
selection: { start: start - m, end: end - m }
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
if (selected.length > 2 * m && selected.startsWith(marker) && selected.endsWith(marker)) {
|
|
1796
|
+
const inner = selected.slice(m, -m);
|
|
1797
|
+
return { value: before + inner + after, selection: { start, end: start + inner.length } };
|
|
1798
|
+
}
|
|
1799
|
+
return {
|
|
1800
|
+
value: before + marker + selected + marker + after,
|
|
1801
|
+
selection: { start: start + m, end: end + m }
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
if (kind === "link") {
|
|
1805
|
+
const text = selected || "text";
|
|
1806
|
+
const url = "https://";
|
|
1807
|
+
const next2 = `${before}[${text}](${url})${after}`;
|
|
1808
|
+
const urlStart = start + text.length + 3;
|
|
1809
|
+
return { value: next2, selection: { start: urlStart, end: urlStart + url.length } };
|
|
1810
|
+
}
|
|
1811
|
+
if (kind === "codeBlock") {
|
|
1812
|
+
const lead = before === "" || before.endsWith("\n") ? "" : "\n";
|
|
1813
|
+
const tail = after === "" || after.startsWith("\n") ? "" : "\n";
|
|
1814
|
+
const block2 = `${lead}\`\`\`
|
|
1815
|
+
${selected}
|
|
1816
|
+
\`\`\`${tail}`;
|
|
1817
|
+
const innerStart = start + lead.length + 4;
|
|
1818
|
+
return {
|
|
1819
|
+
value: before + block2 + after,
|
|
1820
|
+
selection: { start: innerStart, end: innerStart + selected.length }
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
if (kind === "table") {
|
|
1824
|
+
const lead = before === "" || before.endsWith("\n") ? "" : "\n";
|
|
1825
|
+
const header = selected.trim() || "Column";
|
|
1826
|
+
const table = `${lead}| ${header} | Column |
|
|
1827
|
+
| --- | --- |
|
|
1828
|
+
| | |
|
|
1829
|
+
`;
|
|
1830
|
+
const cell = start + table.length - 6;
|
|
1831
|
+
return { value: before + table + after, selection: { start: cell, end: cell } };
|
|
1832
|
+
}
|
|
1833
|
+
const lineStart = value.lastIndexOf("\n", start - 1) + 1;
|
|
1834
|
+
const nl = value.indexOf("\n", end);
|
|
1835
|
+
const lineEnd = nl === -1 ? value.length : nl;
|
|
1836
|
+
const lines = value.slice(lineStart, lineEnd).split("\n");
|
|
1837
|
+
const numbered = /^\d+\. /;
|
|
1838
|
+
const prefix = LINE_PREFIX[kind];
|
|
1839
|
+
const has = (line) => kind === "numberedList" ? numbered.test(line) : line.startsWith(prefix);
|
|
1840
|
+
const allHave = lines.every(has);
|
|
1841
|
+
const nextLines = lines.map((line, i) => {
|
|
1842
|
+
if (allHave)
|
|
1843
|
+
return kind === "numberedList" ? line.replace(numbered, "") : line.slice(prefix.length);
|
|
1844
|
+
const bare = line.replace(/^(\d+\. |- \[[ xX]\] |- |\* |> )/, "");
|
|
1845
|
+
return (kind === "numberedList" ? `${i + 1}. ` : prefix) + bare;
|
|
1846
|
+
});
|
|
1847
|
+
const block = nextLines.join("\n");
|
|
1848
|
+
const next = value.slice(0, lineStart) + block + value.slice(lineEnd);
|
|
1849
|
+
if (start === end) {
|
|
1850
|
+
const caret = lineStart + nextLines[0].length;
|
|
1851
|
+
return { value: next, selection: { start: caret, end: caret } };
|
|
1852
|
+
}
|
|
1853
|
+
return { value: next, selection: { start: lineStart, end: lineStart + block.length } };
|
|
1854
|
+
}
|
|
1855
|
+
function formatForShortcut(e) {
|
|
1856
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey) return null;
|
|
1857
|
+
const key = e.key.toLowerCase();
|
|
1858
|
+
if (e.shiftKey) return key === "x" ? "strike" : null;
|
|
1859
|
+
switch (key) {
|
|
1860
|
+
case "b":
|
|
1861
|
+
return "bold";
|
|
1862
|
+
case "i":
|
|
1863
|
+
return "italic";
|
|
1864
|
+
case "e":
|
|
1865
|
+
return "code";
|
|
1866
|
+
case "k":
|
|
1867
|
+
return "link";
|
|
1868
|
+
default:
|
|
1869
|
+
return null;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
function slashQuery(value, caret) {
|
|
1873
|
+
if (!value.startsWith("/")) return null;
|
|
1874
|
+
const head = value.slice(1, caret);
|
|
1875
|
+
if (caret < 1 || /\s/.test(head)) return null;
|
|
1876
|
+
const end = value.search(/\s/);
|
|
1877
|
+
if (end !== -1 && caret > end) return null;
|
|
1878
|
+
return { query: head.toLowerCase() };
|
|
1879
|
+
}
|
|
1880
|
+
function filterSlashCommands(commands, query, limit = 8) {
|
|
1881
|
+
const q = query.toLowerCase();
|
|
1882
|
+
const prefix = [];
|
|
1883
|
+
const contains = [];
|
|
1884
|
+
for (const c of commands) {
|
|
1885
|
+
const name = c.name.toLowerCase();
|
|
1886
|
+
if (name.startsWith(q)) prefix.push(c);
|
|
1887
|
+
else if (q && (name.includes(q) || c.description?.toLowerCase().includes(q))) contains.push(c);
|
|
1888
|
+
}
|
|
1889
|
+
prefix.sort((a, b) => a.name.localeCompare(b.name));
|
|
1890
|
+
return [...prefix, ...contains].slice(0, limit);
|
|
1891
|
+
}
|
|
1892
|
+
function applySlashCommand(value, name) {
|
|
1893
|
+
const end = value.search(/\s/);
|
|
1894
|
+
const rest = end === -1 ? "" : value.slice(end).replace(/^\s+/, "");
|
|
1895
|
+
const head = `/${name} `;
|
|
1896
|
+
return { value: head + rest, selection: { start: head.length, end: head.length } };
|
|
1897
|
+
}
|
|
1898
|
+
function slashCommandsFromWorkspace(commands) {
|
|
1899
|
+
return commands.map((c) => ({
|
|
1900
|
+
name: c.command,
|
|
1901
|
+
...c.description ? { description: c.description } : {},
|
|
1902
|
+
...c.usage ? { usage: c.usage } : {},
|
|
1903
|
+
...c.app?.name ? { source: c.app.name } : {}
|
|
1904
|
+
}));
|
|
1905
|
+
}
|
|
1906
|
+
function parseSlashCommand(value) {
|
|
1907
|
+
const m = /^\/([a-z0-9_-]+)(?:\s+([\s\S]*))?$/i.exec(value.trim());
|
|
1908
|
+
if (!m) return null;
|
|
1909
|
+
return { name: m[1].toLowerCase(), args: (m[2] ?? "").trim() };
|
|
1910
|
+
}
|
|
1911
|
+
function rankMentionGroups(groups, query, limit = 8) {
|
|
1912
|
+
const q = query.toLowerCase();
|
|
1913
|
+
const scored = [];
|
|
1914
|
+
for (const g of groups) {
|
|
1915
|
+
const handle = g.handle.toLowerCase();
|
|
1916
|
+
const name = g.name.toLowerCase();
|
|
1917
|
+
const score = q === "" ? 1 : handle.startsWith(q) ? 3 : name.split(/\s+/).some((w) => w.startsWith(q)) ? 2 : handle.includes(q) || name.includes(q) ? 1 : 0;
|
|
1918
|
+
if (score > 0) scored.push({ g, score });
|
|
1919
|
+
}
|
|
1920
|
+
scored.sort((a, b) => b.score - a.score || a.g.handle.localeCompare(b.g.handle));
|
|
1921
|
+
return scored.slice(0, limit).map((s) => s.g);
|
|
1922
|
+
}
|
|
1923
|
+
function mentionGroupMeta(g) {
|
|
1924
|
+
if (g.description) return g.description;
|
|
1925
|
+
if (g.memberCount === void 0) return null;
|
|
1926
|
+
return `${g.memberCount} ${g.memberCount === 1 ? "person" : "people"}`;
|
|
1927
|
+
}
|
|
1928
|
+
var MESSAGE_PLAYBACK_RATES = [1, 1.5, 2];
|
|
1929
|
+
function nextPlaybackRate(rate) {
|
|
1930
|
+
const i = MESSAGE_PLAYBACK_RATES.indexOf(rate);
|
|
1931
|
+
return MESSAGE_PLAYBACK_RATES[(i + 1) % MESSAGE_PLAYBACK_RATES.length];
|
|
1932
|
+
}
|
|
1933
|
+
function playbackRateLabel(rate) {
|
|
1934
|
+
return `${rate}\xD7`;
|
|
1935
|
+
}
|
|
1936
|
+
function waveformBars(samples, bars) {
|
|
1937
|
+
if (bars <= 0) return [];
|
|
1938
|
+
if (samples.length === 0) return new Array(bars).fill(0.08);
|
|
1939
|
+
const out = [];
|
|
1940
|
+
for (let i = 0; i < bars; i++) {
|
|
1941
|
+
const from = Math.floor(i * samples.length / bars);
|
|
1942
|
+
const to = Math.max(from + 1, Math.floor((i + 1) * samples.length / bars));
|
|
1943
|
+
let peak = 0;
|
|
1944
|
+
for (let j = from; j < to && j < samples.length; j++) peak = Math.max(peak, samples[j]);
|
|
1945
|
+
out.push(Math.max(0.08, Math.min(1, peak)));
|
|
1946
|
+
}
|
|
1947
|
+
return out;
|
|
1948
|
+
}
|
|
1949
|
+
var WARN_CODES = /* @__PURE__ */ new Set(["dlp_warning"]);
|
|
1950
|
+
var BLOCK_CODES = /* @__PURE__ */ new Set(["dlp_blocked"]);
|
|
1951
|
+
function readDlpError(err) {
|
|
1952
|
+
if (!(err instanceof sdk.ApiError)) return null;
|
|
1953
|
+
const code = String(err.code);
|
|
1954
|
+
const action = WARN_CODES.has(code) ? "warn" : BLOCK_CODES.has(code) ? "block" : null;
|
|
1955
|
+
if (!action) return null;
|
|
1956
|
+
const details = err.details ?? {};
|
|
1957
|
+
const raw = Array.isArray(details.rules) ? details.rules : Array.isArray(details.matches) ? details.matches : [];
|
|
1958
|
+
const matches = [];
|
|
1959
|
+
for (const m of raw) {
|
|
1960
|
+
if (!m || typeof m !== "object") continue;
|
|
1961
|
+
const r = m;
|
|
1962
|
+
const rule = typeof r.name === "string" ? r.name : typeof r.rule === "string" ? r.rule : null;
|
|
1963
|
+
if (!rule) continue;
|
|
1964
|
+
matches.push({ rule, ...typeof r.excerpt === "string" ? { excerpt: r.excerpt } : {} });
|
|
1965
|
+
}
|
|
1966
|
+
const message = typeof details.message === "string" ? details.message : void 0;
|
|
1967
|
+
return { action, matches, ...message ? { message } : {} };
|
|
1968
|
+
}
|
|
1717
1969
|
function computeGroupPosition(msg, prev, next, windowMs) {
|
|
1718
1970
|
const continuesPrev = sameGroup(msg, prev, windowMs);
|
|
1719
1971
|
const continuesNext = sameGroup(next, msg, windowMs);
|
|
@@ -1769,6 +2021,10 @@ function useCallRoom(conversationId, opts) {
|
|
|
1769
2021
|
const [error, setError] = react.useState(null);
|
|
1770
2022
|
const [sfuAvailable, setSfuAvailable] = react.useState(null);
|
|
1771
2023
|
const [canPublish, setCanPublish] = react.useState(true);
|
|
2024
|
+
const [background, setBackgroundState] = react.useState({ type: "none" });
|
|
2025
|
+
const [noiseSuppression, setNoise] = react.useState(opts.noiseSuppression ?? true);
|
|
2026
|
+
const [reconnecting, setReconnecting] = react.useState(false);
|
|
2027
|
+
const [disconnectReason, setDisconnectReason] = react.useState(null);
|
|
1772
2028
|
const optsRef = react.useRef(opts);
|
|
1773
2029
|
optsRef.current = opts;
|
|
1774
2030
|
const joined = react.useRef(false);
|
|
@@ -1781,7 +2037,9 @@ function useCallRoom(conversationId, opts) {
|
|
|
1781
2037
|
...optsRef.current.muted !== void 0 ? { muted: optsRef.current.muted } : {},
|
|
1782
2038
|
...optsRef.current.facing !== void 0 ? { facing: optsRef.current.facing } : {},
|
|
1783
2039
|
...optsRef.current.aloneGraceMs !== void 0 ? { aloneGraceMs: optsRef.current.aloneGraceMs } : {},
|
|
1784
|
-
...optsRef.current.republishOnPermission !== void 0 ? { republishOnPermission: optsRef.current.republishOnPermission } : {}
|
|
2040
|
+
...optsRef.current.republishOnPermission !== void 0 ? { republishOnPermission: optsRef.current.republishOnPermission } : {},
|
|
2041
|
+
...optsRef.current.trackProcessors ? { trackProcessors: optsRef.current.trackProcessors } : {},
|
|
2042
|
+
...optsRef.current.noiseSuppression !== void 0 ? { noiseSuppression: optsRef.current.noiseSuppression } : {}
|
|
1785
2043
|
});
|
|
1786
2044
|
}, [poolse, conversationId]);
|
|
1787
2045
|
const refreshDevices = react.useCallback((target) => {
|
|
@@ -1827,6 +2085,12 @@ function useCallRoom(conversationId, opts) {
|
|
|
1827
2085
|
const offDevices = room.onDevices(() => refreshDevices(room));
|
|
1828
2086
|
const offError = room.onError(setError);
|
|
1829
2087
|
const offPublish = room.onPublishPermission(() => sync(room));
|
|
2088
|
+
setReconnecting(room.isReconnecting());
|
|
2089
|
+
setDisconnectReason(null);
|
|
2090
|
+
setBackgroundState(room.getBackground());
|
|
2091
|
+
setNoise(room.isNoiseSuppressionEnabled());
|
|
2092
|
+
const offReconnect = room.onReconnecting(setReconnecting);
|
|
2093
|
+
const offDisconnect = room.onDisconnected(setDisconnectReason);
|
|
1830
2094
|
return () => {
|
|
1831
2095
|
offStatus();
|
|
1832
2096
|
offRoster();
|
|
@@ -1834,6 +2098,8 @@ function useCallRoom(conversationId, opts) {
|
|
|
1834
2098
|
offDevices();
|
|
1835
2099
|
offError();
|
|
1836
2100
|
offPublish();
|
|
2101
|
+
offReconnect();
|
|
2102
|
+
offDisconnect();
|
|
1837
2103
|
held.current = null;
|
|
1838
2104
|
if (joined.current) {
|
|
1839
2105
|
joined.current = false;
|
|
@@ -1931,7 +2197,30 @@ function useCallRoom(conversationId, opts) {
|
|
|
1931
2197
|
await room.republish();
|
|
1932
2198
|
sync(room);
|
|
1933
2199
|
}, [room, sync]);
|
|
2200
|
+
const setBackground = react.useCallback(
|
|
2201
|
+
async (effect) => {
|
|
2202
|
+
if (!room) return false;
|
|
2203
|
+
setBackgroundState(effect);
|
|
2204
|
+
return room.setBackground(effect);
|
|
2205
|
+
},
|
|
2206
|
+
[room]
|
|
2207
|
+
);
|
|
2208
|
+
const setNoiseSuppression = react.useCallback(
|
|
2209
|
+
async (enabled) => {
|
|
2210
|
+
setNoise(enabled);
|
|
2211
|
+
await room?.setNoiseSuppression(enabled);
|
|
2212
|
+
},
|
|
2213
|
+
[room]
|
|
2214
|
+
);
|
|
1934
2215
|
return {
|
|
2216
|
+
room,
|
|
2217
|
+
backgroundSupported: room?.backgroundSupported() ?? false,
|
|
2218
|
+
background,
|
|
2219
|
+
setBackground,
|
|
2220
|
+
noiseSuppression,
|
|
2221
|
+
setNoiseSuppression,
|
|
2222
|
+
reconnecting,
|
|
2223
|
+
disconnectReason,
|
|
1935
2224
|
status,
|
|
1936
2225
|
participants,
|
|
1937
2226
|
cameraEnabled,
|
|
@@ -2177,138 +2466,707 @@ function useRoom(conversationId, opts) {
|
|
|
2177
2466
|
error: error ?? media.error
|
|
2178
2467
|
};
|
|
2179
2468
|
}
|
|
2180
|
-
|
|
2469
|
+
var asError = (err) => err instanceof Error ? err : new Error(String(err));
|
|
2470
|
+
function onReconnect2(chat, fn) {
|
|
2471
|
+
let was = chat.realtime.getStatus() === "connected";
|
|
2472
|
+
let before = was;
|
|
2473
|
+
return chat.realtime.onStatus((status) => {
|
|
2474
|
+
if (status === "connected" && !was && before) fn();
|
|
2475
|
+
was = status === "connected";
|
|
2476
|
+
before ||= was;
|
|
2477
|
+
});
|
|
2478
|
+
}
|
|
2479
|
+
function useLiveValue(conversationId, callId, load, listen, subscribeOpts = {}) {
|
|
2181
2480
|
const chat = usePoolse();
|
|
2182
|
-
const
|
|
2183
|
-
const [state, setState] = react.useState(
|
|
2184
|
-
() => initial && initial.id === callId ? { recording: initial.recording ?? null, transcription: initial.transcription ?? null } : { recording: null, transcription: null }
|
|
2185
|
-
);
|
|
2186
|
-
const [notice, setNotice] = react.useState(null);
|
|
2187
|
-
const [lastRecording, setLastRecording] = react.useState(null);
|
|
2188
|
-
const [pending, setPending] = react.useState(false);
|
|
2481
|
+
const [value, setValue] = react.useState(null);
|
|
2189
2482
|
const [error, setError] = react.useState(null);
|
|
2190
|
-
const [
|
|
2483
|
+
const [pending, setPending] = react.useState(false);
|
|
2484
|
+
const loadRef = react.useRef(load);
|
|
2485
|
+
loadRef.current = load;
|
|
2486
|
+
const listenRef = react.useRef(listen);
|
|
2487
|
+
listenRef.current = listen;
|
|
2191
2488
|
const seq = react.useRef(0);
|
|
2192
|
-
const
|
|
2489
|
+
const selfUserId = subscribeOpts.selfUserId ?? null;
|
|
2193
2490
|
const refresh = react.useCallback(() => {
|
|
2194
|
-
if (!callId
|
|
2491
|
+
if (!callId) return;
|
|
2195
2492
|
const mine = ++seq.current;
|
|
2196
|
-
|
|
2197
|
-
if (mine
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
else
|
|
2201
|
-
setState((s) => ({
|
|
2202
|
-
recording: s.recording ? { ...s.recording, active: false } : null,
|
|
2203
|
-
transcription: s.transcription ? { ...s.transcription, active: false } : null
|
|
2204
|
-
}));
|
|
2205
|
-
}).catch(() => {
|
|
2493
|
+
loadRef.current(chat, callId).then((v) => {
|
|
2494
|
+
if (mine === seq.current) setValue(v);
|
|
2495
|
+
}).catch((err) => {
|
|
2496
|
+
if (mine === seq.current) setError(asError(err));
|
|
2206
2497
|
});
|
|
2207
|
-
}, [chat, callId
|
|
2498
|
+
}, [chat, callId]);
|
|
2208
2499
|
react.useEffect(() => {
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
}
|
|
2224
|
-
});
|
|
2225
|
-
const conv = chat.realtime.conversation(conversationId);
|
|
2226
|
-
const offFinished = conv.onCallFinished((evt) => {
|
|
2227
|
-
if (evt.call_id !== callId) return;
|
|
2228
|
-
seq.current++;
|
|
2229
|
-
setState((s) => ({
|
|
2230
|
-
recording: s.recording ? { ...s.recording, active: false } : null,
|
|
2231
|
-
transcription: s.transcription ? { ...s.transcription, active: false } : null
|
|
2232
|
-
}));
|
|
2233
|
-
});
|
|
2234
|
-
const offStatus = onReconnect(chat, refresh);
|
|
2500
|
+
setValue(null);
|
|
2501
|
+
setError(null);
|
|
2502
|
+
if (!callId || !conversationId) return;
|
|
2503
|
+
refresh();
|
|
2504
|
+
const off = chat.live.subscribe(
|
|
2505
|
+
conversationId,
|
|
2506
|
+
callId,
|
|
2507
|
+
listenRef.current((fn) => {
|
|
2508
|
+
seq.current++;
|
|
2509
|
+
setValue((prev) => fn(prev));
|
|
2510
|
+
}),
|
|
2511
|
+
selfUserId ? { selfUserId } : {}
|
|
2512
|
+
);
|
|
2513
|
+
const offStatus = onReconnect2(chat, refresh);
|
|
2235
2514
|
return () => {
|
|
2236
|
-
|
|
2237
|
-
offFinished();
|
|
2515
|
+
off();
|
|
2238
2516
|
offStatus();
|
|
2239
2517
|
};
|
|
2240
|
-
}, [chat, callId,
|
|
2241
|
-
const
|
|
2518
|
+
}, [chat, conversationId, callId, refresh, selfUserId]);
|
|
2519
|
+
const run = react.useCallback(
|
|
2520
|
+
async (fn, apply) => {
|
|
2521
|
+
setPending(true);
|
|
2522
|
+
setError(null);
|
|
2523
|
+
try {
|
|
2524
|
+
const r = await fn();
|
|
2525
|
+
if (apply) {
|
|
2526
|
+
seq.current++;
|
|
2527
|
+
apply(r);
|
|
2528
|
+
}
|
|
2529
|
+
return r;
|
|
2530
|
+
} catch (err) {
|
|
2531
|
+
setError(asError(err));
|
|
2532
|
+
return null;
|
|
2533
|
+
} finally {
|
|
2534
|
+
setPending(false);
|
|
2535
|
+
}
|
|
2536
|
+
},
|
|
2537
|
+
[]
|
|
2538
|
+
);
|
|
2539
|
+
return { chat, value, setValue, error, pending, refresh, run };
|
|
2540
|
+
}
|
|
2541
|
+
function useStage(conversationId, callId, selfUserId) {
|
|
2542
|
+
const { chat, value, setValue, error, pending, run } = useLiveValue(
|
|
2543
|
+
conversationId,
|
|
2544
|
+
callId,
|
|
2545
|
+
(c, id) => c.live.stage.get(id),
|
|
2546
|
+
(set) => ({ onStage: (s) => set(() => s) }),
|
|
2547
|
+
{ selfUserId: selfUserId ?? null }
|
|
2548
|
+
);
|
|
2549
|
+
const ok = (r) => r !== null;
|
|
2550
|
+
const raiseHand = react.useCallback(
|
|
2551
|
+
async () => callId ? ok(await run(() => chat.live.stage.raiseHand(callId), setValue)) : false,
|
|
2552
|
+
[chat, callId, run, setValue]
|
|
2553
|
+
);
|
|
2554
|
+
const lowerHand = react.useCallback(
|
|
2555
|
+
async (userId) => callId ? ok(await run(() => chat.live.stage.lowerHand(callId, userId), setValue)) : false,
|
|
2556
|
+
[chat, callId, run, setValue]
|
|
2557
|
+
);
|
|
2558
|
+
const setRole = react.useCallback(
|
|
2559
|
+
async (userId, role) => callId ? ok(await run(() => chat.live.stage.setRole(callId, userId, role), setValue)) : false,
|
|
2560
|
+
[chat, callId, run, setValue]
|
|
2561
|
+
);
|
|
2562
|
+
const setMode = react.useCallback(
|
|
2563
|
+
async (mode) => callId ? ok(await run(() => chat.live.stage.setMode(callId, mode), setValue)) : false,
|
|
2564
|
+
[chat, callId, run, setValue]
|
|
2565
|
+
);
|
|
2566
|
+
const roleOf = react.useCallback((userId) => sdk.stageRoleOf(value, userId), [value]);
|
|
2567
|
+
const myRole = value?.myRole ?? "speaker";
|
|
2568
|
+
return {
|
|
2569
|
+
stage: value,
|
|
2570
|
+
myRole,
|
|
2571
|
+
isModerator: myRole === "moderator",
|
|
2572
|
+
handRaised: !!selfUserId && !!value?.hands.some((h) => h.userId === selfUserId),
|
|
2573
|
+
roleOf,
|
|
2574
|
+
raiseHand,
|
|
2575
|
+
lowerHand,
|
|
2576
|
+
setRole,
|
|
2577
|
+
setMode,
|
|
2578
|
+
error,
|
|
2579
|
+
pending
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
function useQuestions(conversationId, callId) {
|
|
2583
|
+
const mineVoted = react.useRef(/* @__PURE__ */ new Set());
|
|
2584
|
+
const merge = (list, q) => {
|
|
2585
|
+
if (q.votedByMe) mineVoted.current.add(q.id);
|
|
2586
|
+
const withMine = { ...q, votedByMe: q.votedByMe || mineVoted.current.has(q.id) };
|
|
2587
|
+
const i = list.findIndex((x) => x.id === q.id);
|
|
2588
|
+
if (i < 0) return [...list, withMine];
|
|
2589
|
+
const next = list.slice();
|
|
2590
|
+
next[i] = withMine;
|
|
2591
|
+
return next;
|
|
2592
|
+
};
|
|
2593
|
+
const { chat, value, setValue, error, pending, run } = useLiveValue(
|
|
2594
|
+
conversationId,
|
|
2595
|
+
callId,
|
|
2596
|
+
async (c, id) => {
|
|
2597
|
+
const list = await c.live.questions.list(id);
|
|
2598
|
+
list.forEach((q) => q.votedByMe && mineVoted.current.add(q.id));
|
|
2599
|
+
return list;
|
|
2600
|
+
},
|
|
2601
|
+
(set) => ({
|
|
2602
|
+
onQuestion: (q) => set((prev) => merge(prev ?? [], q)),
|
|
2603
|
+
onQuestionDeleted: (id) => set((prev) => (prev ?? []).filter((q) => q.id !== id))
|
|
2604
|
+
})
|
|
2605
|
+
);
|
|
2606
|
+
const apply = react.useCallback(
|
|
2607
|
+
(q) => setValue((prev) => merge(prev ?? [], q)),
|
|
2608
|
+
// merge only reads the ref.
|
|
2609
|
+
[setValue]
|
|
2610
|
+
);
|
|
2611
|
+
const ask = react.useCallback(
|
|
2612
|
+
async (text, opts) => {
|
|
2613
|
+
if (!callId || !text.trim()) return false;
|
|
2614
|
+
return await run(() => chat.live.questions.ask(callId, text, opts ?? {}), apply) !== null;
|
|
2615
|
+
},
|
|
2616
|
+
[chat, callId, run, apply]
|
|
2617
|
+
);
|
|
2618
|
+
const toggleVote2 = react.useCallback(
|
|
2619
|
+
async (questionId) => {
|
|
2620
|
+
const voted = mineVoted.current.has(questionId);
|
|
2621
|
+
if (voted) mineVoted.current.delete(questionId);
|
|
2622
|
+
else mineVoted.current.add(questionId);
|
|
2623
|
+
const r = await run(
|
|
2624
|
+
() => voted ? chat.live.questions.unvote(questionId) : chat.live.questions.vote(questionId),
|
|
2625
|
+
(q) => apply({ ...q, votedByMe: !voted })
|
|
2626
|
+
);
|
|
2627
|
+
if (r === null) {
|
|
2628
|
+
if (voted) mineVoted.current.add(questionId);
|
|
2629
|
+
else mineVoted.current.delete(questionId);
|
|
2630
|
+
}
|
|
2631
|
+
},
|
|
2632
|
+
[chat, run, apply]
|
|
2633
|
+
);
|
|
2634
|
+
const setStatus = react.useCallback(
|
|
2635
|
+
async (questionId, status) => {
|
|
2636
|
+
await run(() => chat.live.questions.setStatus(questionId, status), apply);
|
|
2637
|
+
},
|
|
2638
|
+
[chat, run, apply]
|
|
2639
|
+
);
|
|
2640
|
+
const questions = react.useMemo(() => sdk.sortQuestions(value ?? []), [value]);
|
|
2641
|
+
return {
|
|
2642
|
+
questions,
|
|
2643
|
+
openCount: questions.filter((q) => q.status === "open").length,
|
|
2644
|
+
ask,
|
|
2645
|
+
toggleVote: toggleVote2,
|
|
2646
|
+
setStatus,
|
|
2647
|
+
error,
|
|
2648
|
+
pending
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
function useBreakouts(conversationId, callId, opts = {}) {
|
|
2652
|
+
const { chat, value, setValue, error, pending, run } = useLiveValue(
|
|
2653
|
+
conversationId,
|
|
2654
|
+
callId,
|
|
2655
|
+
(c, id) => c.live.breakouts.get(id),
|
|
2656
|
+
(set) => ({ onBreakouts: (b) => set(() => b.status === "closed" ? null : b) })
|
|
2657
|
+
);
|
|
2658
|
+
const session = value ?? null;
|
|
2659
|
+
const [now, setNow] = react.useState(() => Date.now());
|
|
2660
|
+
const deadline = session?.status === "closing" ? session.returnAt : session?.endsAt;
|
|
2242
2661
|
react.useEffect(() => {
|
|
2243
|
-
if (!
|
|
2244
|
-
|
|
2245
|
-
|
|
2662
|
+
if (!deadline) return;
|
|
2663
|
+
const t = setInterval(() => setNow(Date.now()), 1e3);
|
|
2664
|
+
return () => clearInterval(t);
|
|
2665
|
+
}, [deadline]);
|
|
2666
|
+
const at = deadline ? Date.parse(deadline) : NaN;
|
|
2667
|
+
const secondsLeft = Number.isFinite(at) ? Math.max(0, Math.ceil((at - now) / 1e3)) : null;
|
|
2668
|
+
const open = react.useCallback(
|
|
2669
|
+
async (plan) => callId ? await run(() => chat.live.breakouts.open(callId, plan), setValue) !== null : false,
|
|
2670
|
+
[chat, callId, run, setValue]
|
|
2671
|
+
);
|
|
2672
|
+
const close = react.useCallback(
|
|
2673
|
+
async (afterSeconds) => callId ? await run(() => chat.live.breakouts.close(callId, afterSeconds), setValue) !== null : false,
|
|
2674
|
+
[chat, callId, run, setValue]
|
|
2675
|
+
);
|
|
2676
|
+
const join = react.useCallback(
|
|
2677
|
+
(roomId) => run(() => chat.live.breakouts.join(roomId)),
|
|
2678
|
+
[chat, run]
|
|
2679
|
+
);
|
|
2680
|
+
const returnToMain = react.useCallback(
|
|
2681
|
+
() => callId ? run(() => chat.live.breakouts.returnToMain(callId)) : Promise.resolve(null),
|
|
2682
|
+
[chat, callId, run]
|
|
2683
|
+
);
|
|
2684
|
+
const optsRef = react.useRef(opts);
|
|
2685
|
+
optsRef.current = opts;
|
|
2686
|
+
const inRoom = react.useRef(null);
|
|
2687
|
+
const myRoomId = session?.status === "open" ? session.myRoomId : null;
|
|
2688
|
+
react.useEffect(() => {
|
|
2689
|
+
if (!optsRef.current.auto || !callId) return;
|
|
2690
|
+
if (myRoomId && inRoom.current !== myRoomId) {
|
|
2691
|
+
const room = session?.rooms.find((r) => r.id === myRoomId);
|
|
2692
|
+
inRoom.current = myRoomId;
|
|
2693
|
+
void chat.live.breakouts.join(myRoomId).then((s) => room && optsRef.current.onJoinRoom?.(s, room)).catch(() => {
|
|
2694
|
+
inRoom.current = null;
|
|
2695
|
+
});
|
|
2696
|
+
} else if (!session && inRoom.current) {
|
|
2697
|
+
inRoom.current = null;
|
|
2698
|
+
void chat.live.breakouts.returnToMain(callId).then((s) => optsRef.current.onReturn?.(s)).catch(() => {
|
|
2699
|
+
});
|
|
2246
2700
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2701
|
+
}, [chat, callId, myRoomId, session]);
|
|
2702
|
+
return {
|
|
2703
|
+
session,
|
|
2704
|
+
myRoom: session?.rooms.find((r) => r.id === session.myRoomId) ?? null,
|
|
2705
|
+
secondsLeft,
|
|
2706
|
+
open,
|
|
2707
|
+
close,
|
|
2708
|
+
join,
|
|
2709
|
+
returnToMain,
|
|
2710
|
+
error,
|
|
2711
|
+
pending
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
function useLobby(conversationId, callId = null) {
|
|
2715
|
+
const chat = usePoolse();
|
|
2716
|
+
const [lobby, setLobby] = react.useState(null);
|
|
2717
|
+
const [error, setError] = react.useState(null);
|
|
2718
|
+
const [pending, setPending] = react.useState(false);
|
|
2719
|
+
const seq = react.useRef(0);
|
|
2720
|
+
const target = react.useMemo(
|
|
2721
|
+
() => conversationId ? { conversationId, callId } : null,
|
|
2722
|
+
[conversationId, callId]
|
|
2723
|
+
);
|
|
2724
|
+
const refresh = react.useCallback(() => {
|
|
2725
|
+
if (!target) return;
|
|
2726
|
+
const mine = ++seq.current;
|
|
2727
|
+
chat.live.lobby.get(target).then((l) => {
|
|
2728
|
+
if (mine === seq.current) setLobby(l);
|
|
2729
|
+
}).catch((err) => {
|
|
2730
|
+
if (mine === seq.current) setError(asError(err));
|
|
2731
|
+
});
|
|
2732
|
+
}, [chat, target]);
|
|
2733
|
+
react.useEffect(() => {
|
|
2734
|
+
setLobby(null);
|
|
2735
|
+
setError(null);
|
|
2736
|
+
if (!target) return;
|
|
2737
|
+
refresh();
|
|
2738
|
+
const off = chat.live.subscribe(target.conversationId, target.callId ?? "", {
|
|
2739
|
+
onLobby: (l) => {
|
|
2740
|
+
seq.current++;
|
|
2741
|
+
setLobby(l);
|
|
2742
|
+
}
|
|
2251
2743
|
});
|
|
2744
|
+
const offStatus = onReconnect2(chat, refresh);
|
|
2252
2745
|
return () => {
|
|
2253
|
-
|
|
2746
|
+
off();
|
|
2747
|
+
offStatus();
|
|
2254
2748
|
};
|
|
2255
|
-
}, [chat,
|
|
2256
|
-
const
|
|
2749
|
+
}, [chat, target, refresh]);
|
|
2750
|
+
const act = react.useCallback(async (fn) => {
|
|
2257
2751
|
setPending(true);
|
|
2258
2752
|
setError(null);
|
|
2259
2753
|
try {
|
|
2260
|
-
await fn();
|
|
2754
|
+
const l = await fn();
|
|
2755
|
+
seq.current++;
|
|
2756
|
+
setLobby(l);
|
|
2261
2757
|
return true;
|
|
2262
2758
|
} catch (err) {
|
|
2263
|
-
setError(
|
|
2759
|
+
setError(asError(err));
|
|
2264
2760
|
return false;
|
|
2265
2761
|
} finally {
|
|
2266
2762
|
setPending(false);
|
|
2267
2763
|
}
|
|
2268
2764
|
}, []);
|
|
2269
|
-
const
|
|
2270
|
-
(
|
|
2271
|
-
|
|
2272
|
-
const r = await chat.calls.recording.start(callId, mode ? { mode } : {});
|
|
2273
|
-
setLastRecording(r);
|
|
2274
|
-
}),
|
|
2275
|
-
[chat, callId, run]
|
|
2765
|
+
const admit = react.useCallback(
|
|
2766
|
+
(id) => target ? act(() => chat.live.lobby.admit(target, id)) : Promise.resolve(false),
|
|
2767
|
+
[chat, target, act]
|
|
2276
2768
|
);
|
|
2277
|
-
const
|
|
2278
|
-
() =>
|
|
2279
|
-
|
|
2280
|
-
const r = await chat.calls.recording.stop(callId);
|
|
2281
|
-
setLastRecording(r);
|
|
2282
|
-
}),
|
|
2283
|
-
[chat, callId, run]
|
|
2769
|
+
const deny = react.useCallback(
|
|
2770
|
+
(id) => target ? act(() => chat.live.lobby.deny(target, id)) : Promise.resolve(false),
|
|
2771
|
+
[chat, target, act]
|
|
2284
2772
|
);
|
|
2285
|
-
const
|
|
2286
|
-
(
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2773
|
+
const admitAll = react.useCallback(
|
|
2774
|
+
() => target ? act(() => chat.live.lobby.admitAll(target)) : Promise.resolve(false),
|
|
2775
|
+
[chat, target, act]
|
|
2776
|
+
);
|
|
2777
|
+
return { lobby, waitingCount: lobby?.waiting.length ?? 0, admit, deny, admitAll, error, pending };
|
|
2778
|
+
}
|
|
2779
|
+
function useMoments(conversationId, callId) {
|
|
2780
|
+
const add = (list, m) => (list ?? []).some((x) => x.id === m.id) ? list ?? [] : [...list ?? [], m];
|
|
2781
|
+
const { chat, value, setValue, error, pending, run } = useLiveValue(
|
|
2782
|
+
conversationId,
|
|
2783
|
+
callId,
|
|
2784
|
+
(c, id) => c.live.moments.list(id),
|
|
2785
|
+
(set) => ({ onMoment: (m) => set((prev) => add(prev, m)) })
|
|
2786
|
+
);
|
|
2787
|
+
const [lastMarked, setLast] = react.useState(null);
|
|
2788
|
+
const mark = react.useCallback(
|
|
2789
|
+
async (note) => {
|
|
2790
|
+
if (!callId) return null;
|
|
2791
|
+
const m = await run(
|
|
2792
|
+
() => chat.live.moments.mark(callId, note ? { note } : {}),
|
|
2793
|
+
(r) => setValue((prev) => add(prev, r))
|
|
2294
2794
|
);
|
|
2295
|
-
|
|
2296
|
-
|
|
2795
|
+
if (m) setLast(m);
|
|
2796
|
+
return m;
|
|
2797
|
+
},
|
|
2798
|
+
[chat, callId, run, setValue]
|
|
2799
|
+
);
|
|
2800
|
+
return { moments: value ?? [], mark, lastMarked, error, pending };
|
|
2801
|
+
}
|
|
2802
|
+
function useAgenda(conversationId, callId) {
|
|
2803
|
+
const [overtime, setOvertime] = react.useState(null);
|
|
2804
|
+
const { chat, value, setValue, error, pending, run } = useLiveValue(
|
|
2805
|
+
conversationId,
|
|
2806
|
+
callId,
|
|
2807
|
+
(c, id) => c.live.agenda.get(id),
|
|
2808
|
+
(set) => ({
|
|
2809
|
+
onAgenda: (a) => set(() => a),
|
|
2810
|
+
onAgendaOvertime: (o) => setOvertime({ itemId: o.itemId, overByMs: o.overByMs })
|
|
2811
|
+
})
|
|
2812
|
+
);
|
|
2813
|
+
const agenda = value ?? null;
|
|
2814
|
+
const current = agenda?.items.find((i) => i.id === agenda.currentItemId) ?? null;
|
|
2815
|
+
const [now, setNow] = react.useState(() => Date.now());
|
|
2816
|
+
react.useEffect(() => {
|
|
2817
|
+
if (!current?.minutes || current.status !== "active") return;
|
|
2818
|
+
const t = setInterval(() => setNow(Date.now()), 5e3);
|
|
2819
|
+
return () => clearInterval(t);
|
|
2820
|
+
}, [current?.id, current?.minutes, current?.status]);
|
|
2821
|
+
react.useEffect(() => {
|
|
2822
|
+
setOvertime((o) => o && o.itemId !== current?.id ? null : o);
|
|
2823
|
+
}, [current?.id]);
|
|
2824
|
+
const act = react.useCallback(
|
|
2825
|
+
async (fn) => await run(fn, setValue) !== null,
|
|
2826
|
+
[run, setValue]
|
|
2297
2827
|
);
|
|
2298
|
-
const rec = state.recording;
|
|
2299
|
-
const active = !!rec?.active;
|
|
2300
|
-
const capturing = active || transcribing;
|
|
2301
|
-
const consentRequired = active && !!rec?.consent_required || transcribing && transcriptConsent;
|
|
2302
|
-
const myConsent = meId && rec ? rec.consent.accepted.includes(meId) || active && rec.started_by_user_id === meId ? "accepted" : rec.consent.declined.includes(meId) ? "declined" : null : null;
|
|
2303
2828
|
return {
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2829
|
+
agenda,
|
|
2830
|
+
current,
|
|
2831
|
+
overrunMs: current ? sdk.agendaOverrunMs(current, now) : 0,
|
|
2832
|
+
overtime,
|
|
2833
|
+
start: react.useCallback(
|
|
2834
|
+
(id) => callId ? act(() => chat.live.agenda.start(callId, id)) : Promise.resolve(false),
|
|
2835
|
+
[chat, callId, act]
|
|
2836
|
+
),
|
|
2837
|
+
done: react.useCallback(
|
|
2838
|
+
(id) => callId ? act(() => chat.live.agenda.done(callId, id)) : Promise.resolve(false),
|
|
2839
|
+
[chat, callId, act]
|
|
2840
|
+
),
|
|
2841
|
+
reopen: react.useCallback(
|
|
2842
|
+
(id) => callId ? act(() => chat.live.agenda.reopen(callId, id)) : Promise.resolve(false),
|
|
2843
|
+
[chat, callId, act]
|
|
2844
|
+
),
|
|
2845
|
+
error,
|
|
2846
|
+
pending
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
function useCallReactions(room, opts = {}) {
|
|
2850
|
+
const visibleMs = opts.visibleMs ?? 4e3;
|
|
2851
|
+
const max = opts.max ?? 30;
|
|
2852
|
+
const [reactions, setReactions] = react.useState([]);
|
|
2853
|
+
const ref = react.useRef(null);
|
|
2854
|
+
react.useEffect(() => {
|
|
2855
|
+
setReactions([]);
|
|
2856
|
+
if (!room) return;
|
|
2857
|
+
const r = new sdk.CallReactions(room);
|
|
2858
|
+
ref.current = r;
|
|
2859
|
+
const timers = /* @__PURE__ */ new Set();
|
|
2860
|
+
const off = r.subscribe((reaction) => {
|
|
2861
|
+
setReactions((list) => [...list, reaction].slice(-max));
|
|
2862
|
+
const t = setTimeout(() => {
|
|
2863
|
+
timers.delete(t);
|
|
2864
|
+
setReactions((list) => list.filter((x) => x.id !== reaction.id));
|
|
2865
|
+
}, visibleMs);
|
|
2866
|
+
timers.add(t);
|
|
2867
|
+
});
|
|
2868
|
+
return () => {
|
|
2869
|
+
off();
|
|
2870
|
+
timers.forEach(clearTimeout);
|
|
2871
|
+
r.destroy();
|
|
2872
|
+
ref.current = null;
|
|
2873
|
+
};
|
|
2874
|
+
}, [room, visibleMs, max]);
|
|
2875
|
+
const send = react.useCallback(
|
|
2876
|
+
(emoji) => ref.current?.send(emoji) ?? Promise.resolve(false),
|
|
2877
|
+
[]
|
|
2878
|
+
);
|
|
2879
|
+
return { reactions, send };
|
|
2880
|
+
}
|
|
2881
|
+
function useScreenAnnotations(room, sharerUserId, opts = {}) {
|
|
2882
|
+
const [state, setState] = react.useState(null);
|
|
2883
|
+
const [annotations, setAnnotations] = react.useState(null);
|
|
2884
|
+
const fadeMs = opts.fadeMs;
|
|
2885
|
+
react.useEffect(() => {
|
|
2886
|
+
setState(null);
|
|
2887
|
+
setAnnotations(null);
|
|
2888
|
+
if (!room || !sharerUserId) return;
|
|
2889
|
+
const layer = new sdk.ScreenAnnotations(room, sharerUserId, fadeMs ? { fadeMs } : {});
|
|
2890
|
+
setAnnotations(layer);
|
|
2891
|
+
const off = layer.subscribe(setState);
|
|
2892
|
+
return () => {
|
|
2893
|
+
off();
|
|
2894
|
+
layer.destroy();
|
|
2895
|
+
};
|
|
2896
|
+
}, [room, sharerUserId, fadeMs]);
|
|
2897
|
+
return { state, annotations };
|
|
2898
|
+
}
|
|
2899
|
+
function useCallQuality(room, opts = {}) {
|
|
2900
|
+
const chat = usePoolse();
|
|
2901
|
+
const [report, setReport] = react.useState(null);
|
|
2902
|
+
const intervalMs = opts.intervalMs;
|
|
2903
|
+
const callId = opts.callId ?? null;
|
|
2904
|
+
react.useEffect(() => {
|
|
2905
|
+
setReport(null);
|
|
2906
|
+
if (!room) return;
|
|
2907
|
+
const monitor = new sdk.CallQualityMonitor(room, {
|
|
2908
|
+
...intervalMs ? { intervalMs } : {},
|
|
2909
|
+
...callId ? { report: (body) => chat.live.quality.report(callId, body) } : {}
|
|
2910
|
+
});
|
|
2911
|
+
const off = monitor.subscribe(setReport);
|
|
2912
|
+
return () => {
|
|
2913
|
+
off();
|
|
2914
|
+
monitor.stop();
|
|
2915
|
+
};
|
|
2916
|
+
}, [chat, room, intervalMs, callId]);
|
|
2917
|
+
return report;
|
|
2918
|
+
}
|
|
2919
|
+
function useCallMeeting(conversationId, callId) {
|
|
2920
|
+
const { value, refresh } = useLiveValue(
|
|
2921
|
+
conversationId,
|
|
2922
|
+
callId,
|
|
2923
|
+
(c, id) => c.live.meeting(id),
|
|
2924
|
+
(set) => ({
|
|
2925
|
+
onAttendees: (attendees2) => set((m) => m ? { ...m, attendees: attendees2 } : m),
|
|
2926
|
+
onQuality: (q) => set((m) => m ? { ...m, quality: { ...m.quality, [q.identity]: q } } : m),
|
|
2927
|
+
onCaptions: (c) => set((m) => m ? { ...m, captionsUserIds: c.userIds } : m),
|
|
2928
|
+
onBreakouts: (b) => set((m) => m ? { ...m, breakout: b.status === "closed" ? null : b } : m),
|
|
2929
|
+
onLobby: (l) => set((m) => m ? { ...m, lobbyWaiting: l.waiting.length } : m),
|
|
2930
|
+
onStage: (s) => set((m) => m ? { ...m, stage: s.mode === "stage", roles: s.roles, hands: s.hands } : m)
|
|
2931
|
+
})
|
|
2932
|
+
);
|
|
2933
|
+
const attendees = react.useMemo(() => value?.attendees ?? [], [value]);
|
|
2934
|
+
const nameOf = react.useCallback(
|
|
2935
|
+
(identity, nameFor) => {
|
|
2936
|
+
const a = attendees.find((x) => x.identity === identity);
|
|
2937
|
+
if (a) return a.name;
|
|
2938
|
+
return sdk.meetingNameOf(identity, nameFor?.(identity) ?? null);
|
|
2939
|
+
},
|
|
2940
|
+
[attendees]
|
|
2941
|
+
);
|
|
2942
|
+
return { meeting: value, attendees, quality: value?.quality ?? {}, nameOf, refresh };
|
|
2943
|
+
}
|
|
2944
|
+
function useCaptions(conversationId, callId, selfUserId) {
|
|
2945
|
+
const { chat, value, setValue, error, pending, run } = useLiveValue(
|
|
2946
|
+
conversationId,
|
|
2947
|
+
callId,
|
|
2948
|
+
async (c, id) => (await c.live.meeting(id)).captionsUserIds,
|
|
2949
|
+
(set) => ({ onCaptions: (cap) => set(() => cap.userIds) })
|
|
2950
|
+
);
|
|
2951
|
+
const userIds = react.useMemo(() => value ?? [], [value]);
|
|
2952
|
+
const on = !!selfUserId && userIds.includes(selfUserId);
|
|
2953
|
+
const setOn = react.useCallback(
|
|
2954
|
+
async (next) => {
|
|
2955
|
+
if (!callId) return false;
|
|
2956
|
+
const r = await run(
|
|
2957
|
+
() => chat.live.captions.set(callId, next),
|
|
2958
|
+
(cap) => setValue(() => cap.userIds)
|
|
2959
|
+
);
|
|
2960
|
+
return r !== null;
|
|
2961
|
+
},
|
|
2962
|
+
[chat, callId, run, setValue]
|
|
2963
|
+
);
|
|
2964
|
+
const toggle = react.useCallback(() => setOn(!on), [setOn, on]);
|
|
2965
|
+
return { on, userIds, setOn, toggle, error, pending };
|
|
2966
|
+
}
|
|
2967
|
+
function useWhiteboard(callId, Y, opts = {}) {
|
|
2968
|
+
const chat = usePoolse();
|
|
2969
|
+
const [items, setItems] = react.useState([]);
|
|
2970
|
+
const [board, setBoard] = react.useState(null);
|
|
2971
|
+
const [error, setError] = react.useState(null);
|
|
2972
|
+
const optsRef = react.useRef(opts);
|
|
2973
|
+
optsRef.current = opts;
|
|
2974
|
+
const selfUserId = opts.selfUserId ?? null;
|
|
2975
|
+
react.useEffect(() => {
|
|
2976
|
+
setItems([]);
|
|
2977
|
+
setBoard(null);
|
|
2978
|
+
setError(null);
|
|
2979
|
+
if (!callId || !Y) return;
|
|
2980
|
+
let cancelled = false;
|
|
2981
|
+
let open = null;
|
|
2982
|
+
let off = null;
|
|
2983
|
+
const access = () => optsRef.current.access?.(callId) ?? chat.live.whiteboard(callId);
|
|
2984
|
+
access().then((a) => {
|
|
2985
|
+
if (cancelled) return;
|
|
2986
|
+
open = sdk.openWhiteboard(chat, Y, a, { selfUserId, refreshAccess: access });
|
|
2987
|
+
off = open.model.subscribe(setItems);
|
|
2988
|
+
setBoard(open);
|
|
2989
|
+
}).catch((err) => {
|
|
2990
|
+
if (!cancelled) setError(asError(err));
|
|
2991
|
+
});
|
|
2992
|
+
return () => {
|
|
2993
|
+
cancelled = true;
|
|
2994
|
+
off?.();
|
|
2995
|
+
open?.close();
|
|
2996
|
+
};
|
|
2997
|
+
}, [chat, callId, Y, selfUserId]);
|
|
2998
|
+
return { items, model: board?.model ?? null, readOnly: board ? board.readOnly() : true, error };
|
|
2999
|
+
}
|
|
3000
|
+
function useRoomPresence() {
|
|
3001
|
+
const chat = usePoolse();
|
|
3002
|
+
const { me } = useMe();
|
|
3003
|
+
const meId = me?.id ?? null;
|
|
3004
|
+
const [rooms, setRooms] = react.useState([]);
|
|
3005
|
+
const [presence, setPresence] = react.useState({});
|
|
3006
|
+
const refresh = react.useCallback(() => {
|
|
3007
|
+
chat.live.rooms().then((list) => {
|
|
3008
|
+
setRooms(list);
|
|
3009
|
+
setPresence((p) => {
|
|
3010
|
+
const next = { ...p };
|
|
3011
|
+
for (const r of list) next[r.conversationId] = r.presence;
|
|
3012
|
+
return next;
|
|
3013
|
+
});
|
|
3014
|
+
}).catch(() => {
|
|
3015
|
+
});
|
|
3016
|
+
}, [chat]);
|
|
3017
|
+
react.useEffect(() => {
|
|
3018
|
+
if (!meId) return;
|
|
3019
|
+
refresh();
|
|
3020
|
+
const off = chat.live.subscribeUser(meId, {
|
|
3021
|
+
onRoomParticipants: (r) => {
|
|
3022
|
+
setPresence((p) => ({ ...p, [r.conversationId]: r }));
|
|
3023
|
+
setRooms(
|
|
3024
|
+
(list) => list.map(
|
|
3025
|
+
(room) => room.conversationId === r.conversationId ? { ...room, presence: r } : room
|
|
3026
|
+
)
|
|
3027
|
+
);
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
const offStatus = onReconnect2(chat, refresh);
|
|
3031
|
+
return () => {
|
|
3032
|
+
off();
|
|
3033
|
+
offStatus();
|
|
3034
|
+
};
|
|
3035
|
+
}, [chat, meId, refresh]);
|
|
3036
|
+
return { rooms, presence, refresh };
|
|
3037
|
+
}
|
|
3038
|
+
function useRecording(callId, conversationId, initial) {
|
|
3039
|
+
const chat = usePoolse();
|
|
3040
|
+
const meId = useMeId(chat);
|
|
3041
|
+
const [state, setState] = react.useState(
|
|
3042
|
+
() => initial && initial.id === callId ? { recording: initial.recording ?? null, transcription: initial.transcription ?? null } : { recording: null, transcription: null }
|
|
3043
|
+
);
|
|
3044
|
+
const [notice, setNotice] = react.useState(null);
|
|
3045
|
+
const [lastRecording, setLastRecording] = react.useState(null);
|
|
3046
|
+
const [pending, setPending] = react.useState(false);
|
|
3047
|
+
const [error, setError] = react.useState(null);
|
|
3048
|
+
const [transcriptConsent, setTranscriptConsent] = react.useState(false);
|
|
3049
|
+
const seq = react.useRef(0);
|
|
3050
|
+
const hasInitial = react.useRef(!!initial && initial.id === callId);
|
|
3051
|
+
const refresh = react.useCallback(() => {
|
|
3052
|
+
if (!callId || !conversationId) return;
|
|
3053
|
+
const mine = ++seq.current;
|
|
3054
|
+
chat.liveCalls.get(conversationId).then((c) => {
|
|
3055
|
+
if (mine !== seq.current) return;
|
|
3056
|
+
if (c && c.id === callId)
|
|
3057
|
+
setState({ recording: c.recording ?? null, transcription: c.transcription ?? null });
|
|
3058
|
+
else
|
|
3059
|
+
setState((s) => ({
|
|
3060
|
+
recording: s.recording ? { ...s.recording, active: false } : null,
|
|
3061
|
+
transcription: s.transcription ? { ...s.transcription, active: false } : null
|
|
3062
|
+
}));
|
|
3063
|
+
}).catch(() => {
|
|
3064
|
+
});
|
|
3065
|
+
}, [chat, callId, conversationId]);
|
|
3066
|
+
react.useEffect(() => {
|
|
3067
|
+
if (!callId || !conversationId) {
|
|
3068
|
+
setState({ recording: null, transcription: null });
|
|
3069
|
+
return;
|
|
3070
|
+
}
|
|
3071
|
+
if (hasInitial.current) hasInitial.current = false;
|
|
3072
|
+
else refresh();
|
|
3073
|
+
const offCapture = subscribeCapture(chat, conversationId, callId, (e) => {
|
|
3074
|
+
seq.current++;
|
|
3075
|
+
setState((s) => applyCaptureEvent(s, e));
|
|
3076
|
+
if (e.type === "recording:started") {
|
|
3077
|
+
setNotice(e.evt.notice);
|
|
3078
|
+
setLastRecording(e.evt.recording);
|
|
3079
|
+
} else if (e.type === "recording:stopped" || e.type === "recording:ready") {
|
|
3080
|
+
setLastRecording(e.evt.recording);
|
|
3081
|
+
}
|
|
3082
|
+
});
|
|
3083
|
+
const conv = chat.realtime.conversation(conversationId);
|
|
3084
|
+
const offFinished = conv.onCallFinished((evt) => {
|
|
3085
|
+
if (evt.call_id !== callId) return;
|
|
3086
|
+
seq.current++;
|
|
3087
|
+
setState((s) => ({
|
|
3088
|
+
recording: s.recording ? { ...s.recording, active: false } : null,
|
|
3089
|
+
transcription: s.transcription ? { ...s.transcription, active: false } : null
|
|
3090
|
+
}));
|
|
3091
|
+
});
|
|
3092
|
+
const offStatus = onReconnect(chat, refresh);
|
|
3093
|
+
return () => {
|
|
3094
|
+
offCapture();
|
|
3095
|
+
offFinished();
|
|
3096
|
+
offStatus();
|
|
3097
|
+
};
|
|
3098
|
+
}, [chat, callId, conversationId, refresh]);
|
|
3099
|
+
const transcribing = !!state.transcription?.active;
|
|
3100
|
+
react.useEffect(() => {
|
|
3101
|
+
if (!conversationId || !transcribing) {
|
|
3102
|
+
setTranscriptConsent(false);
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
let cancelled = false;
|
|
3106
|
+
chat.calls.recording.settings(conversationId).then((s) => {
|
|
3107
|
+
if (!cancelled) setTranscriptConsent(s.effective.consent === "required");
|
|
3108
|
+
}).catch(() => {
|
|
3109
|
+
});
|
|
3110
|
+
return () => {
|
|
3111
|
+
cancelled = true;
|
|
3112
|
+
};
|
|
3113
|
+
}, [chat, conversationId, transcribing]);
|
|
3114
|
+
const run = react.useCallback(async (fn) => {
|
|
3115
|
+
setPending(true);
|
|
3116
|
+
setError(null);
|
|
3117
|
+
try {
|
|
3118
|
+
await fn();
|
|
3119
|
+
return true;
|
|
3120
|
+
} catch (err) {
|
|
3121
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
3122
|
+
return false;
|
|
3123
|
+
} finally {
|
|
3124
|
+
setPending(false);
|
|
3125
|
+
}
|
|
3126
|
+
}, []);
|
|
3127
|
+
const start = react.useCallback(
|
|
3128
|
+
(mode) => run(async () => {
|
|
3129
|
+
if (!callId) throw new Error("no call");
|
|
3130
|
+
const r = await chat.calls.recording.start(callId, mode ? { mode } : {});
|
|
3131
|
+
setLastRecording(r);
|
|
3132
|
+
}),
|
|
3133
|
+
[chat, callId, run]
|
|
3134
|
+
);
|
|
3135
|
+
const stop = react.useCallback(
|
|
3136
|
+
() => run(async () => {
|
|
3137
|
+
if (!callId) throw new Error("no call");
|
|
3138
|
+
const r = await chat.calls.recording.stop(callId);
|
|
3139
|
+
setLastRecording(r);
|
|
3140
|
+
}),
|
|
3141
|
+
[chat, callId, run]
|
|
3142
|
+
);
|
|
3143
|
+
const consent = react.useCallback(
|
|
3144
|
+
(decision) => run(async () => {
|
|
3145
|
+
if (!callId) throw new Error("no call");
|
|
3146
|
+
const res = await chat.calls.consent(callId, decision);
|
|
3147
|
+
setState(
|
|
3148
|
+
(s) => applyCaptureEvent(s, {
|
|
3149
|
+
type: "recording:consent",
|
|
3150
|
+
evt: { cv: 1, call_id: res.call_id, user_id: res.user_id, decision: res.decision }
|
|
3151
|
+
})
|
|
3152
|
+
);
|
|
3153
|
+
}),
|
|
3154
|
+
[chat, callId, run]
|
|
3155
|
+
);
|
|
3156
|
+
const rec = state.recording;
|
|
3157
|
+
const active = !!rec?.active;
|
|
3158
|
+
const capturing = active || transcribing;
|
|
3159
|
+
const consentRequired = active && !!rec?.consent_required || transcribing && transcriptConsent;
|
|
3160
|
+
const myConsent = meId && rec ? rec.consent.accepted.includes(meId) || active && rec.started_by_user_id === meId ? "accepted" : rec.consent.declined.includes(meId) ? "declined" : null : null;
|
|
3161
|
+
return {
|
|
3162
|
+
available: rec?.available ?? false,
|
|
3163
|
+
active,
|
|
3164
|
+
recording: rec,
|
|
3165
|
+
transcription: state.transcription,
|
|
3166
|
+
capturing,
|
|
3167
|
+
consentRequired,
|
|
3168
|
+
myConsent,
|
|
3169
|
+
needsConsent: capturing && consentRequired && myConsent !== "accepted",
|
|
2312
3170
|
notice,
|
|
2313
3171
|
lastRecording,
|
|
2314
3172
|
pending,
|
|
@@ -2591,59 +3449,1250 @@ function canEditOwnMessage(args) {
|
|
|
2591
3449
|
const sent = Date.parse(args.insertedAt);
|
|
2592
3450
|
return Number.isFinite(sent) && (args.now ?? Date.now()) - sent < EDIT_WINDOW_MS;
|
|
2593
3451
|
}
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
});
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
}
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
3452
|
+
function useApprovals(opts = {}) {
|
|
3453
|
+
const chat = usePoolse();
|
|
3454
|
+
const pollMs = opts.pollMs ?? 6e4;
|
|
3455
|
+
const [approvals, setApprovals] = react.useState(() => chat.approvals.pending());
|
|
3456
|
+
const [loading, setLoading] = react.useState(true);
|
|
3457
|
+
const [error, setError] = react.useState(null);
|
|
3458
|
+
const mounted = react.useRef(true);
|
|
3459
|
+
const refresh = react.useCallback(async () => {
|
|
3460
|
+
try {
|
|
3461
|
+
await chat.approvals.list();
|
|
3462
|
+
if (mounted.current) setError(null);
|
|
3463
|
+
} catch (err) {
|
|
3464
|
+
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
3465
|
+
} finally {
|
|
3466
|
+
if (mounted.current) setLoading(false);
|
|
3467
|
+
}
|
|
3468
|
+
}, [chat]);
|
|
3469
|
+
react.useEffect(() => {
|
|
3470
|
+
mounted.current = true;
|
|
3471
|
+
const off = chat.approvals.subscribe(() => setApprovals(chat.approvals.pending()));
|
|
3472
|
+
setApprovals(chat.approvals.pending());
|
|
3473
|
+
void refresh();
|
|
3474
|
+
void chat.agents.list().catch(() => void 0);
|
|
3475
|
+
const offStatus = onReconnect(chat, () => void refresh());
|
|
3476
|
+
const timer = pollMs > 0 ? setInterval(() => void refresh(), pollMs) : null;
|
|
3477
|
+
return () => {
|
|
3478
|
+
mounted.current = false;
|
|
3479
|
+
off();
|
|
3480
|
+
offStatus();
|
|
3481
|
+
if (timer) clearInterval(timer);
|
|
3482
|
+
};
|
|
3483
|
+
}, [chat, refresh, pollMs]);
|
|
3484
|
+
const approve = react.useCallback(
|
|
3485
|
+
(id, reason) => chat.approvals.approve(id, reason !== void 0 ? { reason } : {}),
|
|
3486
|
+
[chat]
|
|
3487
|
+
);
|
|
3488
|
+
const deny = react.useCallback(
|
|
3489
|
+
(id, reason) => chat.approvals.deny(id, reason !== void 0 ? { reason } : {}),
|
|
3490
|
+
[chat]
|
|
3491
|
+
);
|
|
3492
|
+
return { approvals, loading, error, refresh, approve, deny };
|
|
3493
|
+
}
|
|
3494
|
+
function useApproval(source) {
|
|
3495
|
+
const chat = usePoolse();
|
|
3496
|
+
const id = typeof source === "string" ? source : source?.id ?? null;
|
|
3497
|
+
const sourceRef = react.useRef(source);
|
|
3498
|
+
sourceRef.current = source;
|
|
3499
|
+
const read = () => id ? chat.approvals.peek(id) ?? (typeof sourceRef.current === "object" ? sourceRef.current : null) : null;
|
|
3500
|
+
const [approval, setApproval] = react.useState(read);
|
|
3501
|
+
const [loading, setLoading] = react.useState(() => !!id && !read());
|
|
3502
|
+
const [pending, setPending] = react.useState(null);
|
|
3503
|
+
const [error, setError] = react.useState(null);
|
|
3504
|
+
react.useEffect(() => {
|
|
3505
|
+
if (!id) {
|
|
3506
|
+
setApproval(null);
|
|
3507
|
+
setLoading(false);
|
|
3508
|
+
return;
|
|
3509
|
+
}
|
|
3510
|
+
const given = sourceRef.current;
|
|
3511
|
+
if (given && typeof given === "object") chat.approvals._apply(given);
|
|
3512
|
+
const update = () => setApproval(read());
|
|
3513
|
+
const off = chat.approvals.subscribe(update);
|
|
3514
|
+
update();
|
|
3515
|
+
let live = true;
|
|
3516
|
+
if (!chat.approvals.peek(id)) {
|
|
3517
|
+
setLoading(true);
|
|
3518
|
+
void chat.approvals.ensure(id).catch(() => null).finally(() => {
|
|
3519
|
+
if (live) {
|
|
3520
|
+
setLoading(false);
|
|
3521
|
+
update();
|
|
3522
|
+
}
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
3525
|
+
return () => {
|
|
3526
|
+
live = false;
|
|
3527
|
+
off();
|
|
3528
|
+
};
|
|
3529
|
+
}, [chat, id]);
|
|
3530
|
+
const decide = react.useCallback(
|
|
3531
|
+
async (action, reason) => {
|
|
3532
|
+
if (!id) return;
|
|
3533
|
+
setPending(action);
|
|
3534
|
+
setError(null);
|
|
3535
|
+
try {
|
|
3536
|
+
const opts = reason !== void 0 ? { reason } : {};
|
|
3537
|
+
await (action === "approve" ? chat.approvals.approve(id, opts) : chat.approvals.deny(id, opts));
|
|
3538
|
+
} catch (err) {
|
|
3539
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
3540
|
+
throw err;
|
|
3541
|
+
} finally {
|
|
3542
|
+
setPending(null);
|
|
3543
|
+
}
|
|
3544
|
+
},
|
|
3545
|
+
[chat, id]
|
|
3546
|
+
);
|
|
3547
|
+
return {
|
|
3548
|
+
approval,
|
|
3549
|
+
loading,
|
|
3550
|
+
pending,
|
|
3551
|
+
error,
|
|
3552
|
+
approve: (reason) => decide("approve", reason),
|
|
3553
|
+
deny: (reason) => decide("deny", reason)
|
|
3554
|
+
};
|
|
3555
|
+
}
|
|
3556
|
+
var asError2 = (err) => err instanceof Error ? err : new Error(String(err));
|
|
3557
|
+
function useCallAgents(conversationId, callId) {
|
|
3558
|
+
const chat = usePoolse();
|
|
3559
|
+
const [agents, setAgents] = react.useState([]);
|
|
3560
|
+
const [directory, setDirectory] = react.useState([]);
|
|
3561
|
+
const [loading, setLoading] = react.useState(!!callId);
|
|
3562
|
+
const [error, setError] = react.useState(null);
|
|
3563
|
+
const [pending, setPending] = react.useState(null);
|
|
3564
|
+
const [said, setSaid] = react.useState(null);
|
|
3565
|
+
const [nonce, setNonce] = react.useState(0);
|
|
3566
|
+
react.useEffect(() => {
|
|
3567
|
+
setSaid(null);
|
|
3568
|
+
if (!callId || !conversationId) {
|
|
3569
|
+
setAgents([]);
|
|
3570
|
+
setLoading(false);
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3573
|
+
const controller = new AbortController();
|
|
3574
|
+
const load = () => chat.callAgents.list(callId, controller.signal).then((list) => {
|
|
3575
|
+
if (controller.signal.aborted) return;
|
|
3576
|
+
setAgents(list);
|
|
3577
|
+
setError(null);
|
|
3578
|
+
}).catch((err) => {
|
|
3579
|
+
if (!controller.signal.aborted) setError(asError2(err));
|
|
3580
|
+
}).finally(() => {
|
|
3581
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
3582
|
+
});
|
|
3583
|
+
setLoading(true);
|
|
3584
|
+
void load();
|
|
3585
|
+
const off = chat.callAgents.subscribe(conversationId, callId, {
|
|
3586
|
+
onAgents: setAgents,
|
|
3587
|
+
onSaid: setSaid
|
|
3588
|
+
});
|
|
3589
|
+
const offRe = onReconnect(chat, () => void load());
|
|
3590
|
+
return () => {
|
|
3591
|
+
controller.abort();
|
|
3592
|
+
off();
|
|
3593
|
+
offRe();
|
|
3594
|
+
};
|
|
3595
|
+
}, [chat, conversationId, callId, nonce]);
|
|
3596
|
+
react.useEffect(() => {
|
|
3597
|
+
let live = true;
|
|
3598
|
+
chat.agents.list().then((list) => live && setDirectory(list)).catch(() => void 0);
|
|
3599
|
+
return () => {
|
|
3600
|
+
live = false;
|
|
3601
|
+
};
|
|
3602
|
+
}, [chat]);
|
|
3603
|
+
const available = react.useMemo(() => {
|
|
3604
|
+
const inCall = new Set(agents.map((a) => a.agentId));
|
|
3605
|
+
return directory.filter(
|
|
3606
|
+
(a) => a.status === "active" && !a.stopped && a.voiceEnabled && !inCall.has(a.id)
|
|
3607
|
+
);
|
|
3608
|
+
}, [agents, directory]);
|
|
3609
|
+
const run = react.useCallback(async (agentId, fn) => {
|
|
3610
|
+
setPending(agentId);
|
|
3611
|
+
setError(null);
|
|
3612
|
+
try {
|
|
3613
|
+
await fn();
|
|
3614
|
+
} catch (err) {
|
|
3615
|
+
setError(asError2(err));
|
|
3616
|
+
throw err;
|
|
3617
|
+
} finally {
|
|
3618
|
+
setPending(null);
|
|
3619
|
+
}
|
|
3620
|
+
}, []);
|
|
3621
|
+
const upsert = (a) => setAgents((prev) => {
|
|
3622
|
+
const i = prev.findIndex((x) => x.agentId === a.agentId);
|
|
3623
|
+
return i < 0 ? [...prev, a] : prev.map((x, j) => j === i ? a : x);
|
|
3624
|
+
});
|
|
3625
|
+
const invite = react.useCallback(
|
|
3626
|
+
(agentId, mode = "notetaker") => run(agentId, async () => {
|
|
3627
|
+
if (callId) upsert(await chat.callAgents.invite(callId, agentId, mode));
|
|
3628
|
+
}),
|
|
3629
|
+
[chat, callId, run]
|
|
3630
|
+
);
|
|
3631
|
+
const setMode = react.useCallback(
|
|
3632
|
+
(agentId, mode) => run(agentId, async () => {
|
|
3633
|
+
if (callId) upsert(await chat.callAgents.setMode(callId, agentId, mode));
|
|
3634
|
+
}),
|
|
3635
|
+
[chat, callId, run]
|
|
3636
|
+
);
|
|
3637
|
+
const remove = react.useCallback(
|
|
3638
|
+
(agentId) => run(agentId, async () => {
|
|
3639
|
+
if (!callId) return;
|
|
3640
|
+
await chat.callAgents.remove(callId, agentId);
|
|
3641
|
+
setAgents((prev) => prev.filter((x) => x.agentId !== agentId));
|
|
3642
|
+
}),
|
|
3643
|
+
[chat, callId, run]
|
|
3644
|
+
);
|
|
3645
|
+
const agentFor = react.useCallback(
|
|
3646
|
+
(identity) => agents.find((a) => a.userId === identity) ?? null,
|
|
3647
|
+
[agents]
|
|
3648
|
+
);
|
|
3649
|
+
const refresh = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
3650
|
+
return {
|
|
3651
|
+
agents,
|
|
3652
|
+
available,
|
|
3653
|
+
loading,
|
|
3654
|
+
error,
|
|
3655
|
+
pending,
|
|
3656
|
+
invite,
|
|
3657
|
+
setMode,
|
|
3658
|
+
remove,
|
|
3659
|
+
said,
|
|
3660
|
+
agentFor,
|
|
3661
|
+
refresh
|
|
3662
|
+
};
|
|
3663
|
+
}
|
|
3664
|
+
function useWhisper(callId) {
|
|
3665
|
+
const chat = usePoolse();
|
|
3666
|
+
const { me } = useMe();
|
|
3667
|
+
const userId = me?.id ?? null;
|
|
3668
|
+
const [whisper, setWhisper] = react.useState(null);
|
|
3669
|
+
const [hints, setHints] = react.useState([]);
|
|
3670
|
+
const [latest, setLatest] = react.useState(null);
|
|
3671
|
+
const [loading, setLoading] = react.useState(!!callId);
|
|
3672
|
+
const [pending, setPending] = react.useState(false);
|
|
3673
|
+
const [error, setError] = react.useState(null);
|
|
3674
|
+
const onRef = react.useRef(false);
|
|
3675
|
+
onRef.current = whisper?.on ?? false;
|
|
3676
|
+
const merge = react.useCallback((list) => {
|
|
3677
|
+
setHints((prev) => {
|
|
3678
|
+
const byId = new Map(prev.map((h) => [h.id, h]));
|
|
3679
|
+
for (const h of list) byId.set(h.id, h);
|
|
3680
|
+
return [...byId.values()].sort((a, b) => (a.at ?? "").localeCompare(b.at ?? ""));
|
|
3681
|
+
});
|
|
3682
|
+
}, []);
|
|
3683
|
+
react.useEffect(() => {
|
|
3684
|
+
setHints([]);
|
|
3685
|
+
setLatest(null);
|
|
3686
|
+
setWhisper(null);
|
|
3687
|
+
if (!callId) {
|
|
3688
|
+
setLoading(false);
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
const controller = new AbortController();
|
|
3692
|
+
const load = () => chat.callAgents.whisper.get(callId, controller.signal).then((res) => {
|
|
3693
|
+
if (controller.signal.aborted) return;
|
|
3694
|
+
setWhisper(res.whisper);
|
|
3695
|
+
merge(res.hints);
|
|
3696
|
+
setError(null);
|
|
3697
|
+
}).catch((err) => {
|
|
3698
|
+
if (!controller.signal.aborted) setError(asError2(err));
|
|
3699
|
+
}).finally(() => {
|
|
3700
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
3701
|
+
});
|
|
3702
|
+
setLoading(true);
|
|
3703
|
+
void load();
|
|
3704
|
+
const off = userId ? chat.callAgents.whisper.subscribe(userId, callId, {
|
|
3705
|
+
onHint: (h) => {
|
|
3706
|
+
merge([h]);
|
|
3707
|
+
setLatest(h);
|
|
3708
|
+
},
|
|
3709
|
+
onChanged: setWhisper
|
|
3710
|
+
}) : () => void 0;
|
|
3711
|
+
const offRe = onReconnect(chat, () => void load());
|
|
3712
|
+
return () => {
|
|
3713
|
+
controller.abort();
|
|
3714
|
+
off();
|
|
3715
|
+
offRe();
|
|
3716
|
+
};
|
|
3717
|
+
}, [chat, callId, userId, merge]);
|
|
3718
|
+
const setOn = react.useCallback(
|
|
3719
|
+
async (next, opts = {}) => {
|
|
3720
|
+
if (!callId) return;
|
|
3721
|
+
setPending(true);
|
|
3722
|
+
setError(null);
|
|
3723
|
+
try {
|
|
3724
|
+
setWhisper(await chat.callAgents.whisper.set(callId, next, opts));
|
|
3725
|
+
} catch (err) {
|
|
3726
|
+
setError(asError2(err));
|
|
3727
|
+
throw err;
|
|
3728
|
+
} finally {
|
|
3729
|
+
setPending(false);
|
|
3730
|
+
}
|
|
3731
|
+
},
|
|
3732
|
+
[chat, callId]
|
|
3733
|
+
);
|
|
3734
|
+
const toggle = react.useCallback(() => setOn(!onRef.current), [setOn]);
|
|
3735
|
+
return {
|
|
3736
|
+
on: whisper?.on ?? false,
|
|
3737
|
+
whisper,
|
|
3738
|
+
agentName: whisper?.on ? whisper.agent?.name ?? null : null,
|
|
3739
|
+
hints,
|
|
3740
|
+
latest,
|
|
3741
|
+
loading,
|
|
3742
|
+
pending,
|
|
3743
|
+
error,
|
|
3744
|
+
setOn,
|
|
3745
|
+
toggle
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
function useEscalations(opts = {}) {
|
|
3749
|
+
const chat = usePoolse();
|
|
3750
|
+
const pollMs = opts.pollMs ?? 3e4;
|
|
3751
|
+
const callId = opts.callId ?? null;
|
|
3752
|
+
const read = react.useCallback(
|
|
3753
|
+
() => ({
|
|
3754
|
+
pending: chat.escalations.pending().filter((e) => !callId || e.callId === callId),
|
|
3755
|
+
all: chat.escalations.all().filter((e) => !callId || e.callId === callId)
|
|
3756
|
+
}),
|
|
3757
|
+
[chat, callId]
|
|
3758
|
+
);
|
|
3759
|
+
const [state, setState] = react.useState(read);
|
|
3760
|
+
const [loading, setLoading] = react.useState(true);
|
|
3761
|
+
const [error, setError] = react.useState(null);
|
|
3762
|
+
const [pending, setPending] = react.useState(null);
|
|
3763
|
+
const mounted = react.useRef(true);
|
|
3764
|
+
const refresh = react.useCallback(async () => {
|
|
3765
|
+
try {
|
|
3766
|
+
await chat.escalations.list();
|
|
3767
|
+
if (mounted.current) setError(null);
|
|
3768
|
+
} catch (err) {
|
|
3769
|
+
if (mounted.current) setError(asError2(err));
|
|
3770
|
+
} finally {
|
|
3771
|
+
if (mounted.current) setLoading(false);
|
|
3772
|
+
}
|
|
3773
|
+
}, [chat]);
|
|
3774
|
+
react.useEffect(() => {
|
|
3775
|
+
mounted.current = true;
|
|
3776
|
+
const off = chat.escalations.subscribe(() => setState(read()));
|
|
3777
|
+
setState(read());
|
|
3778
|
+
void refresh();
|
|
3779
|
+
const offRe = onReconnect(chat, () => void refresh());
|
|
3780
|
+
const timer = pollMs > 0 ? setInterval(() => void refresh(), pollMs) : null;
|
|
3781
|
+
return () => {
|
|
3782
|
+
mounted.current = false;
|
|
3783
|
+
off();
|
|
3784
|
+
offRe();
|
|
3785
|
+
if (timer) clearInterval(timer);
|
|
3786
|
+
};
|
|
3787
|
+
}, [chat, read, refresh, pollMs]);
|
|
3788
|
+
const reply = react.useCallback(
|
|
3789
|
+
async (id, r) => {
|
|
3790
|
+
setPending(id);
|
|
3791
|
+
setError(null);
|
|
3792
|
+
try {
|
|
3793
|
+
return await chat.escalations.reply(id, r);
|
|
3794
|
+
} catch (err) {
|
|
3795
|
+
if (mounted.current) setError(asError2(err));
|
|
3796
|
+
throw err;
|
|
3797
|
+
} finally {
|
|
3798
|
+
if (mounted.current) setPending(null);
|
|
3799
|
+
}
|
|
3800
|
+
},
|
|
3801
|
+
[chat]
|
|
3802
|
+
);
|
|
3803
|
+
const [, setNames] = react.useState(0);
|
|
3804
|
+
react.useEffect(() => {
|
|
3805
|
+
let live = true;
|
|
3806
|
+
void chat.agents.list().then(() => live && setNames((n) => n + 1)).catch(() => void 0);
|
|
3807
|
+
return () => {
|
|
3808
|
+
live = false;
|
|
3809
|
+
};
|
|
3810
|
+
}, [chat]);
|
|
3811
|
+
const agentNameOf = react.useCallback(
|
|
3812
|
+
(e) => (e.agentId ? chat.agents.peek(e.agentId)?.name : null) ?? "Your agent",
|
|
3813
|
+
[chat]
|
|
3814
|
+
);
|
|
3815
|
+
return {
|
|
3816
|
+
escalations: state.pending,
|
|
3817
|
+
all: state.all,
|
|
3818
|
+
loading,
|
|
3819
|
+
error,
|
|
3820
|
+
pending,
|
|
3821
|
+
reply,
|
|
3822
|
+
agentNameOf,
|
|
3823
|
+
refresh
|
|
3824
|
+
};
|
|
3825
|
+
}
|
|
3826
|
+
function useAgentBrief(target) {
|
|
3827
|
+
const chat = usePoolse();
|
|
3828
|
+
const meetingId = target.scheduledMeetingId ?? null;
|
|
3829
|
+
const callId = target.callId ?? null;
|
|
3830
|
+
const [brief, setBrief] = react.useState(null);
|
|
3831
|
+
const [loading, setLoading] = react.useState(!!(meetingId || callId));
|
|
3832
|
+
const [saving, setSaving] = react.useState(false);
|
|
3833
|
+
const [error, setError] = react.useState(null);
|
|
3834
|
+
const [nonce, setNonce] = react.useState(0);
|
|
3835
|
+
react.useEffect(() => {
|
|
3836
|
+
setBrief(null);
|
|
3837
|
+
if (!meetingId && !callId) {
|
|
3838
|
+
setLoading(false);
|
|
3839
|
+
return;
|
|
3840
|
+
}
|
|
3841
|
+
const controller = new AbortController();
|
|
3842
|
+
setLoading(true);
|
|
3843
|
+
chat.callAgents.briefs.list({
|
|
3844
|
+
...meetingId ? { scheduledMeetingId: meetingId } : {},
|
|
3845
|
+
...callId ? { callId } : {},
|
|
3846
|
+
signal: controller.signal
|
|
3847
|
+
}).then((list) => {
|
|
3848
|
+
if (!controller.signal.aborted) setBrief(list[0] ?? null);
|
|
3849
|
+
}).catch((err) => {
|
|
3850
|
+
if (!controller.signal.aborted) setError(asError2(err));
|
|
3851
|
+
}).finally(() => {
|
|
3852
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
3853
|
+
});
|
|
3854
|
+
return () => controller.abort();
|
|
3855
|
+
}, [chat, meetingId, callId, nonce]);
|
|
3856
|
+
const save = react.useCallback(
|
|
3857
|
+
async (input) => {
|
|
3858
|
+
setSaving(true);
|
|
3859
|
+
setError(null);
|
|
3860
|
+
try {
|
|
3861
|
+
const b = await chat.callAgents.briefs.create({
|
|
3862
|
+
...input,
|
|
3863
|
+
...meetingId ? { scheduledMeetingId: meetingId } : {},
|
|
3864
|
+
...callId && !meetingId ? { callId } : {}
|
|
3865
|
+
});
|
|
3866
|
+
setBrief(b);
|
|
3867
|
+
return b;
|
|
3868
|
+
} catch (err) {
|
|
3869
|
+
setError(asError2(err));
|
|
3870
|
+
throw err;
|
|
3871
|
+
} finally {
|
|
3872
|
+
setSaving(false);
|
|
3873
|
+
}
|
|
3874
|
+
},
|
|
3875
|
+
[chat, meetingId, callId]
|
|
3876
|
+
);
|
|
3877
|
+
const remove = react.useCallback(async () => {
|
|
3878
|
+
if (!brief) return;
|
|
3879
|
+
setSaving(true);
|
|
3880
|
+
setError(null);
|
|
3881
|
+
try {
|
|
3882
|
+
await chat.callAgents.briefs.remove(brief.id);
|
|
3883
|
+
setBrief(null);
|
|
3884
|
+
} catch (err) {
|
|
3885
|
+
setError(asError2(err));
|
|
3886
|
+
throw err;
|
|
3887
|
+
} finally {
|
|
3888
|
+
setSaving(false);
|
|
3889
|
+
}
|
|
3890
|
+
}, [chat, brief]);
|
|
3891
|
+
const refresh = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
3892
|
+
return { brief, loading, saving, error, save, remove, refresh };
|
|
3893
|
+
}
|
|
3894
|
+
function useLoaded(load, key) {
|
|
3895
|
+
const [items, setItems] = react.useState([]);
|
|
3896
|
+
const [loading, setLoading] = react.useState(true);
|
|
3897
|
+
const [error, setError] = react.useState(null);
|
|
3898
|
+
const [nonce, setNonce] = react.useState(0);
|
|
3899
|
+
const loadRef = react.useRef(load);
|
|
3900
|
+
loadRef.current = load;
|
|
3901
|
+
react.useEffect(() => {
|
|
3902
|
+
const controller = new AbortController();
|
|
3903
|
+
setLoading(true);
|
|
3904
|
+
loadRef.current(controller.signal).then((rows) => {
|
|
3905
|
+
if (controller.signal.aborted) return;
|
|
3906
|
+
setItems(rows);
|
|
3907
|
+
setError(null);
|
|
3908
|
+
}).catch((err) => {
|
|
3909
|
+
if (controller.signal.aborted || err?.name === "AbortError") return;
|
|
3910
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
3911
|
+
}).finally(() => {
|
|
3912
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
3913
|
+
});
|
|
3914
|
+
return () => controller.abort();
|
|
3915
|
+
}, [key, nonce]);
|
|
3916
|
+
const refresh = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
3917
|
+
return { items, setItems, loading, error, refresh };
|
|
3918
|
+
}
|
|
3919
|
+
function useAgents() {
|
|
3920
|
+
const chat = usePoolse();
|
|
3921
|
+
const { items, loading, error, refresh } = useLoaded((signal) => chat.agents.list(signal), "all");
|
|
3922
|
+
return { agents: items, loading, error, refresh };
|
|
3923
|
+
}
|
|
3924
|
+
function useConversationAgents(conversationId) {
|
|
3925
|
+
const chat = usePoolse();
|
|
3926
|
+
const { items, setItems, loading, error, refresh } = useLoaded(
|
|
3927
|
+
(signal) => conversationId ? chat.agents.inConversation(conversationId, signal) : Promise.resolve([]),
|
|
3928
|
+
conversationId ?? ""
|
|
3929
|
+
);
|
|
3930
|
+
const put = (scope) => setItems((list) => list.map((a) => a.id === scope.agentId ? { ...a, scope } : a));
|
|
3931
|
+
const setScope = react.useCallback(
|
|
3932
|
+
async (agentId, patch) => {
|
|
3933
|
+
if (!conversationId) throw new Error("no conversation");
|
|
3934
|
+
const scope = await chat.agents.setScope(conversationId, agentId, patch);
|
|
3935
|
+
put(scope);
|
|
3936
|
+
return scope;
|
|
3937
|
+
},
|
|
3938
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3939
|
+
[chat, conversationId]
|
|
3940
|
+
);
|
|
3941
|
+
const resetScope = react.useCallback(
|
|
3942
|
+
async (agentId) => {
|
|
3943
|
+
if (!conversationId) throw new Error("no conversation");
|
|
3944
|
+
const scope = await chat.agents.resetScope(conversationId, agentId);
|
|
3945
|
+
put(scope);
|
|
3946
|
+
return scope;
|
|
3947
|
+
},
|
|
3948
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3949
|
+
[chat, conversationId]
|
|
3950
|
+
);
|
|
3951
|
+
return { agents: items, loading, error, refresh, setScope, resetScope };
|
|
3952
|
+
}
|
|
3953
|
+
function useMemory(opts = {}) {
|
|
3954
|
+
const chat = usePoolse();
|
|
3955
|
+
const key = JSON.stringify([opts.conversationId, opts.kind, opts.q, opts.limit]);
|
|
3956
|
+
const { items, setItems, loading, error, refresh } = useLoaded(
|
|
3957
|
+
(signal) => chat.agents.memory({
|
|
3958
|
+
...opts.conversationId ? { conversationId: opts.conversationId } : {},
|
|
3959
|
+
...opts.kind ? { kind: opts.kind } : {},
|
|
3960
|
+
...opts.q ? { q: opts.q } : {},
|
|
3961
|
+
...opts.limit !== void 0 ? { limit: opts.limit } : {},
|
|
3962
|
+
signal
|
|
3963
|
+
}),
|
|
3964
|
+
key
|
|
3965
|
+
);
|
|
3966
|
+
const add = react.useCallback(
|
|
3967
|
+
async (input) => {
|
|
3968
|
+
const fact = await chat.agents.addMemory(input);
|
|
3969
|
+
setItems((list) => [fact, ...list]);
|
|
3970
|
+
return fact;
|
|
3971
|
+
},
|
|
3972
|
+
[chat, setItems]
|
|
3973
|
+
);
|
|
3974
|
+
const update = react.useCallback(
|
|
3975
|
+
async (id, patch) => {
|
|
3976
|
+
const fact = await chat.agents.updateMemory(id, patch);
|
|
3977
|
+
setItems((list) => list.map((f) => f.id === id ? fact : f));
|
|
3978
|
+
return fact;
|
|
3979
|
+
},
|
|
3980
|
+
[chat, setItems]
|
|
3981
|
+
);
|
|
3982
|
+
const remove = react.useCallback(
|
|
3983
|
+
async (id) => {
|
|
3984
|
+
await chat.agents.deleteMemory(id);
|
|
3985
|
+
setItems((list) => list.filter((f) => f.id !== id));
|
|
3986
|
+
},
|
|
3987
|
+
[chat, setItems]
|
|
3988
|
+
);
|
|
3989
|
+
return { facts: items, loading, error, refresh, add, update, remove };
|
|
3990
|
+
}
|
|
3991
|
+
function useFollowups(opts = {}) {
|
|
3992
|
+
const chat = usePoolse();
|
|
3993
|
+
const { items, setItems, loading, error, refresh } = useLoaded(
|
|
3994
|
+
(signal) => chat.agents.followups({ ...opts.status ? { status: opts.status } : {}, signal }),
|
|
3995
|
+
opts.status ?? ""
|
|
3996
|
+
);
|
|
3997
|
+
const act = react.useCallback(
|
|
3998
|
+
async (id, action) => {
|
|
3999
|
+
const f = await (action === "done" ? chat.agents.followupDone(id) : chat.agents.followupCancel(id));
|
|
4000
|
+
setItems(
|
|
4001
|
+
(list) => opts.status && f.status !== opts.status ? list.filter((x) => x.id !== id) : list.map((x) => x.id === id ? f : x)
|
|
4002
|
+
);
|
|
4003
|
+
return f;
|
|
4004
|
+
},
|
|
4005
|
+
[chat, setItems, opts.status]
|
|
4006
|
+
);
|
|
4007
|
+
return {
|
|
4008
|
+
followups: items,
|
|
4009
|
+
loading,
|
|
4010
|
+
error,
|
|
4011
|
+
refresh,
|
|
4012
|
+
done: (id) => act(id, "done"),
|
|
4013
|
+
cancel: (id) => act(id, "cancel")
|
|
4014
|
+
};
|
|
4015
|
+
}
|
|
4016
|
+
function useAskMeetings(opts = {}) {
|
|
4017
|
+
const chat = usePoolse();
|
|
4018
|
+
const callId = opts.callId ?? null;
|
|
4019
|
+
const conversationId = opts.conversationId ?? null;
|
|
4020
|
+
const [answer, setAnswer] = react.useState(null);
|
|
4021
|
+
const [question, setQuestion] = react.useState(null);
|
|
4022
|
+
const [loading, setLoading] = react.useState(false);
|
|
4023
|
+
const [error, setError] = react.useState(null);
|
|
4024
|
+
const inflight = react.useRef(null);
|
|
4025
|
+
react.useEffect(() => () => inflight.current?.abort(), []);
|
|
4026
|
+
const reset = react.useCallback(() => {
|
|
4027
|
+
inflight.current?.abort();
|
|
4028
|
+
inflight.current = null;
|
|
4029
|
+
setAnswer(null);
|
|
4030
|
+
setQuestion(null);
|
|
4031
|
+
setLoading(false);
|
|
4032
|
+
setError(null);
|
|
4033
|
+
}, []);
|
|
4034
|
+
react.useEffect(() => reset, [callId, conversationId, reset]);
|
|
4035
|
+
const ask = react.useCallback(
|
|
4036
|
+
async (q) => {
|
|
4037
|
+
const text = q.trim().slice(0, sdk.ASK_QUESTION_MAX);
|
|
4038
|
+
if (!text) return null;
|
|
4039
|
+
inflight.current?.abort();
|
|
4040
|
+
const controller = new AbortController();
|
|
4041
|
+
inflight.current = controller;
|
|
4042
|
+
setQuestion(text);
|
|
4043
|
+
setLoading(true);
|
|
4044
|
+
setError(null);
|
|
4045
|
+
try {
|
|
4046
|
+
const res = await chat.meetings.ask({
|
|
4047
|
+
question: text,
|
|
4048
|
+
...callId ? { callId } : {},
|
|
4049
|
+
...conversationId ? { conversationId } : {},
|
|
4050
|
+
signal: controller.signal
|
|
4051
|
+
});
|
|
4052
|
+
if (inflight.current !== controller) return null;
|
|
4053
|
+
setAnswer(res);
|
|
4054
|
+
return res;
|
|
4055
|
+
} catch (err) {
|
|
4056
|
+
if (inflight.current !== controller) return null;
|
|
4057
|
+
if (err?.name === "AbortError") return null;
|
|
4058
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
4059
|
+
return null;
|
|
4060
|
+
} finally {
|
|
4061
|
+
if (inflight.current === controller) {
|
|
4062
|
+
inflight.current = null;
|
|
4063
|
+
setLoading(false);
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
},
|
|
4067
|
+
[chat, callId, conversationId]
|
|
4068
|
+
);
|
|
4069
|
+
return { answer, question, loading, error, ask, reset };
|
|
4070
|
+
}
|
|
4071
|
+
function useRecordingUrl(recordingId) {
|
|
4072
|
+
const chat = usePoolse();
|
|
4073
|
+
const [url, setUrl] = react.useState(null);
|
|
4074
|
+
const [contentType, setContentType] = react.useState(null);
|
|
4075
|
+
const [loading, setLoading] = react.useState(!!recordingId);
|
|
4076
|
+
const [error, setError] = react.useState(null);
|
|
4077
|
+
const [nonce, setNonce] = react.useState(0);
|
|
4078
|
+
react.useEffect(() => {
|
|
4079
|
+
if (!recordingId) {
|
|
4080
|
+
setUrl(null);
|
|
4081
|
+
setLoading(false);
|
|
4082
|
+
setError(null);
|
|
4083
|
+
return;
|
|
4084
|
+
}
|
|
4085
|
+
const controller = new AbortController();
|
|
4086
|
+
setLoading(true);
|
|
4087
|
+
setError(null);
|
|
4088
|
+
chat.calls.recording.downloadUrl(recordingId, controller.signal).then((res) => {
|
|
4089
|
+
if (controller.signal.aborted) return;
|
|
4090
|
+
setUrl(res.url);
|
|
4091
|
+
setContentType(res.content_type);
|
|
4092
|
+
setLoading(false);
|
|
4093
|
+
}).catch((err) => {
|
|
4094
|
+
if (controller.signal.aborted) return;
|
|
4095
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
4096
|
+
setLoading(false);
|
|
4097
|
+
});
|
|
4098
|
+
return () => controller.abort();
|
|
4099
|
+
}, [chat, recordingId, nonce]);
|
|
4100
|
+
const refresh = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
4101
|
+
return { url, contentType, loading, error, refresh };
|
|
4102
|
+
}
|
|
4103
|
+
function useCallSummary(callId, initial = null) {
|
|
4104
|
+
const chat = usePoolse();
|
|
4105
|
+
const [summary, setSummary] = react.useState(initial);
|
|
4106
|
+
const [loading, setLoading] = react.useState(false);
|
|
4107
|
+
const [missing, setMissing] = react.useState(false);
|
|
4108
|
+
const [error, setError] = react.useState(null);
|
|
4109
|
+
const seq = react.useRef(0);
|
|
4110
|
+
const conversationId = initial?.conversationId ?? summary?.conversationId ?? null;
|
|
4111
|
+
const refresh = react.useCallback(() => {
|
|
4112
|
+
if (!callId) return;
|
|
4113
|
+
const mine = ++seq.current;
|
|
4114
|
+
setLoading(true);
|
|
4115
|
+
chat.meetings.summary(callId).then((s) => {
|
|
4116
|
+
if (mine !== seq.current) return;
|
|
4117
|
+
setSummary(s);
|
|
4118
|
+
setMissing(false);
|
|
4119
|
+
setError(null);
|
|
4120
|
+
}).catch((err) => {
|
|
4121
|
+
if (mine !== seq.current) return;
|
|
4122
|
+
if (err instanceof sdk.ApiError && err.status === 404) setMissing(true);
|
|
4123
|
+
else setError(err instanceof Error ? err : new Error(String(err)));
|
|
4124
|
+
}).finally(() => {
|
|
4125
|
+
if (mine === seq.current) setLoading(false);
|
|
4126
|
+
});
|
|
4127
|
+
}, [chat, callId]);
|
|
4128
|
+
const needsFull = !initial || initial.shortened;
|
|
4129
|
+
react.useEffect(() => {
|
|
4130
|
+
if (needsFull) refresh();
|
|
4131
|
+
}, [refresh, needsFull]);
|
|
4132
|
+
react.useEffect(() => {
|
|
4133
|
+
if (!callId || !conversationId) return;
|
|
4134
|
+
return chat.realtime.conversation(conversationId).onSummaryReady((evt) => {
|
|
4135
|
+
if (evt.call_id !== callId) return;
|
|
4136
|
+
const s = sdk.summaryFromWire(evt.summary);
|
|
4137
|
+
if (s) {
|
|
4138
|
+
seq.current++;
|
|
4139
|
+
setSummary(s);
|
|
4140
|
+
}
|
|
4141
|
+
refresh();
|
|
4142
|
+
});
|
|
4143
|
+
}, [chat, callId, conversationId, refresh]);
|
|
4144
|
+
return { summary, loading, missing, error, refresh };
|
|
4145
|
+
}
|
|
4146
|
+
function useRecordingPlayback(recordingId) {
|
|
4147
|
+
const chat = usePoolse();
|
|
4148
|
+
const [playback, setPlayback] = react.useState(null);
|
|
4149
|
+
const [loading, setLoading] = react.useState(!!recordingId);
|
|
4150
|
+
const [error, setError] = react.useState(null);
|
|
4151
|
+
const [nonce, setNonce] = react.useState(0);
|
|
4152
|
+
react.useEffect(() => {
|
|
4153
|
+
if (!recordingId) {
|
|
4154
|
+
setPlayback(null);
|
|
4155
|
+
setLoading(false);
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
const controller = new AbortController();
|
|
4159
|
+
setLoading(true);
|
|
4160
|
+
chat.meetings.playback(recordingId, controller.signal).then((p) => {
|
|
4161
|
+
if (controller.signal.aborted) return;
|
|
4162
|
+
setPlayback(p);
|
|
4163
|
+
setError(null);
|
|
4164
|
+
}).catch((err) => {
|
|
4165
|
+
if (controller.signal.aborted) return;
|
|
4166
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
4167
|
+
}).finally(() => {
|
|
4168
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
4169
|
+
});
|
|
4170
|
+
return () => controller.abort();
|
|
4171
|
+
}, [chat, recordingId, nonce]);
|
|
4172
|
+
const refresh = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
4173
|
+
return { playback, loading, error, refresh };
|
|
4174
|
+
}
|
|
4175
|
+
function useClip(clipId, initial = null) {
|
|
4176
|
+
const chat = usePoolse();
|
|
4177
|
+
const [clip, setClip] = react.useState(initial);
|
|
4178
|
+
const [url, setUrl] = react.useState(null);
|
|
4179
|
+
const [loading, setLoading] = react.useState(!!clipId);
|
|
4180
|
+
const [error, setError] = react.useState(null);
|
|
4181
|
+
const [nonce, setNonce] = react.useState(0);
|
|
4182
|
+
react.useEffect(() => {
|
|
4183
|
+
if (!clipId) {
|
|
4184
|
+
setClip(null);
|
|
4185
|
+
setLoading(false);
|
|
4186
|
+
return;
|
|
4187
|
+
}
|
|
4188
|
+
const controller = new AbortController();
|
|
4189
|
+
setLoading(true);
|
|
4190
|
+
chat.meetings.clip(clipId, controller.signal).then(async (c) => {
|
|
4191
|
+
if (controller.signal.aborted) return;
|
|
4192
|
+
setClip(c);
|
|
4193
|
+
if (c.status === "ready") {
|
|
4194
|
+
const d = await chat.meetings.clipDownloadUrl(clipId, controller.signal);
|
|
4195
|
+
if (!controller.signal.aborted) setUrl(d.url);
|
|
4196
|
+
}
|
|
4197
|
+
setError(null);
|
|
4198
|
+
}).catch((err) => {
|
|
4199
|
+
if (controller.signal.aborted) return;
|
|
4200
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
4201
|
+
}).finally(() => {
|
|
4202
|
+
if (!controller.signal.aborted) setLoading(false);
|
|
4203
|
+
});
|
|
4204
|
+
return () => controller.abort();
|
|
4205
|
+
}, [chat, clipId, nonce]);
|
|
4206
|
+
const conversationId = clip?.conversationId ?? null;
|
|
4207
|
+
react.useEffect(() => {
|
|
4208
|
+
if (!clipId || !conversationId) return;
|
|
4209
|
+
const conv = chat.realtime.conversation(conversationId);
|
|
4210
|
+
const apply = (evt) => {
|
|
4211
|
+
const c = sdk.clipFromWire(evt.clip);
|
|
4212
|
+
if (!c || c.id !== clipId) return;
|
|
4213
|
+
setClip(c);
|
|
4214
|
+
if (c.status === "ready") setNonce((n) => n + 1);
|
|
4215
|
+
if (c.status === "deleted") setUrl(null);
|
|
4216
|
+
};
|
|
4217
|
+
const offs = [conv.onClipReady(apply), conv.onClipDeleted(apply)];
|
|
4218
|
+
return () => offs.forEach((off) => off());
|
|
4219
|
+
}, [chat, clipId, conversationId]);
|
|
4220
|
+
const refresh = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
4221
|
+
return { clip, url, loading, error, refresh };
|
|
4222
|
+
}
|
|
4223
|
+
function usePoll(message) {
|
|
4224
|
+
const chat = usePoolse();
|
|
4225
|
+
const [poll, setPoll] = react.useState(message.poll ?? null);
|
|
4226
|
+
const [mine, setMine] = react.useState(message.my_option_ids ?? []);
|
|
4227
|
+
const [pending, setPending] = react.useState(false);
|
|
4228
|
+
const [error, setError] = react.useState(null);
|
|
4229
|
+
const mineRef = react.useRef(mine);
|
|
4230
|
+
mineRef.current = mine;
|
|
4231
|
+
const pollRef = react.useRef(poll);
|
|
4232
|
+
pollRef.current = poll;
|
|
4233
|
+
const pollKey = JSON.stringify(message.poll ?? null);
|
|
4234
|
+
const mineKey = JSON.stringify(message.my_option_ids ?? null);
|
|
4235
|
+
react.useEffect(() => {
|
|
4236
|
+
setPoll(JSON.parse(pollKey));
|
|
4237
|
+
}, [pollKey]);
|
|
4238
|
+
react.useEffect(() => {
|
|
4239
|
+
const m = JSON.parse(mineKey);
|
|
4240
|
+
if (m) setMine(m);
|
|
4241
|
+
}, [mineKey]);
|
|
4242
|
+
react.useEffect(() => {
|
|
4243
|
+
const conv = chat.realtime.conversation(message.conversation_id);
|
|
4244
|
+
return conv.onPollUpdated((evt) => {
|
|
4245
|
+
if (evt.message_id === message.id) setPoll(evt.poll);
|
|
4246
|
+
});
|
|
4247
|
+
}, [chat, message.id, message.conversation_id]);
|
|
4248
|
+
const write = react.useCallback(
|
|
4249
|
+
async (next) => {
|
|
4250
|
+
const before = mineRef.current;
|
|
4251
|
+
const p = pollRef.current;
|
|
4252
|
+
if (!p) return;
|
|
4253
|
+
const me = chat.me.peek()?.id;
|
|
4254
|
+
setMine(next);
|
|
4255
|
+
setPoll(sdk.applyLocalVote(p, before, next, me));
|
|
4256
|
+
setPending(true);
|
|
4257
|
+
setError(null);
|
|
4258
|
+
try {
|
|
4259
|
+
const res = await chat.messages.one(message.id).vote(next);
|
|
4260
|
+
setPoll(res.poll);
|
|
4261
|
+
setMine(res.my_option_ids);
|
|
4262
|
+
} catch (err) {
|
|
4263
|
+
setMine(before);
|
|
4264
|
+
setPoll(p);
|
|
4265
|
+
setError(err);
|
|
4266
|
+
} finally {
|
|
4267
|
+
setPending(false);
|
|
4268
|
+
}
|
|
4269
|
+
},
|
|
4270
|
+
[chat, message.id]
|
|
4271
|
+
);
|
|
4272
|
+
const closed = poll ? sdk.isPollClosed(poll) : true;
|
|
4273
|
+
return {
|
|
4274
|
+
poll,
|
|
4275
|
+
myOptionIds: mine,
|
|
4276
|
+
closed,
|
|
4277
|
+
pending,
|
|
4278
|
+
error,
|
|
4279
|
+
toggle: async (optionId) => {
|
|
4280
|
+
const p = pollRef.current;
|
|
4281
|
+
if (!p || sdk.isPollClosed(p)) return;
|
|
4282
|
+
await write(sdk.toggleVote(p, mineRef.current, optionId));
|
|
4283
|
+
},
|
|
4284
|
+
clear: () => write([]),
|
|
4285
|
+
close: async () => {
|
|
4286
|
+
setError(null);
|
|
4287
|
+
try {
|
|
4288
|
+
const res = await chat.messages.one(message.id).closePoll();
|
|
4289
|
+
setPoll(res.poll);
|
|
4290
|
+
} catch (err) {
|
|
4291
|
+
setError(err);
|
|
4292
|
+
}
|
|
4293
|
+
}
|
|
4294
|
+
};
|
|
4295
|
+
}
|
|
4296
|
+
function usePins(conversationId) {
|
|
4297
|
+
const chat = usePoolse();
|
|
4298
|
+
const [pins, setPins] = react.useState([]);
|
|
4299
|
+
const [loading, setLoading] = react.useState(true);
|
|
4300
|
+
const [error, setError] = react.useState(null);
|
|
4301
|
+
const refresh = react.useCallback(async () => {
|
|
4302
|
+
try {
|
|
4303
|
+
setPins(await chat.conversations.one(conversationId).messages.pins());
|
|
4304
|
+
setError(null);
|
|
4305
|
+
} catch (err) {
|
|
4306
|
+
setError(err);
|
|
4307
|
+
} finally {
|
|
4308
|
+
setLoading(false);
|
|
4309
|
+
}
|
|
4310
|
+
}, [chat, conversationId]);
|
|
4311
|
+
react.useEffect(() => {
|
|
4312
|
+
setLoading(true);
|
|
4313
|
+
void refresh();
|
|
4314
|
+
const conv = chat.realtime.conversation(conversationId);
|
|
4315
|
+
return conv.onPinChanged(() => void refresh());
|
|
4316
|
+
}, [chat, conversationId, refresh]);
|
|
4317
|
+
return {
|
|
4318
|
+
pins,
|
|
4319
|
+
loading,
|
|
4320
|
+
error,
|
|
4321
|
+
refresh,
|
|
4322
|
+
pin: async (id) => {
|
|
4323
|
+
await chat.messages.one(id).pin();
|
|
4324
|
+
await refresh();
|
|
4325
|
+
},
|
|
4326
|
+
unpin: async (id) => {
|
|
4327
|
+
setPins((p) => p.filter((m) => m.id !== id));
|
|
4328
|
+
await chat.messages.one(id).unpin();
|
|
4329
|
+
await refresh();
|
|
4330
|
+
}
|
|
4331
|
+
};
|
|
4332
|
+
}
|
|
4333
|
+
function useThreadFollow(rootId) {
|
|
4334
|
+
const chat = usePoolse();
|
|
4335
|
+
const [following, setState] = react.useState(null);
|
|
4336
|
+
const [error, setError] = react.useState(null);
|
|
4337
|
+
react.useEffect(() => {
|
|
4338
|
+
if (!rootId) return;
|
|
4339
|
+
let live = true;
|
|
4340
|
+
setState(null);
|
|
4341
|
+
chat.messages.one(rootId).followState().then((s) => live && setState(s.following)).catch((err) => live && setError(err));
|
|
4342
|
+
return () => {
|
|
4343
|
+
live = false;
|
|
4344
|
+
};
|
|
4345
|
+
}, [chat, rootId]);
|
|
4346
|
+
return {
|
|
4347
|
+
following,
|
|
4348
|
+
error,
|
|
4349
|
+
setFollowing: async (on) => {
|
|
4350
|
+
if (!rootId) return;
|
|
4351
|
+
const before = following;
|
|
4352
|
+
setState(on);
|
|
4353
|
+
try {
|
|
4354
|
+
setState((await chat.messages.one(rootId).setFollow(on)).following);
|
|
4355
|
+
} catch (err) {
|
|
4356
|
+
setState(before);
|
|
4357
|
+
setError(err);
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
};
|
|
4361
|
+
}
|
|
4362
|
+
function useCatchUp(conversationId) {
|
|
4363
|
+
const chat = usePoolse();
|
|
4364
|
+
const [result, setResult] = react.useState(null);
|
|
4365
|
+
const [loading, setLoading] = react.useState(false);
|
|
4366
|
+
const [error, setError] = react.useState(null);
|
|
4367
|
+
return {
|
|
4368
|
+
result,
|
|
4369
|
+
loading,
|
|
4370
|
+
error,
|
|
4371
|
+
run: async (opts) => {
|
|
4372
|
+
setLoading(true);
|
|
4373
|
+
setError(null);
|
|
4374
|
+
try {
|
|
4375
|
+
const r = await chat.conversations.one(conversationId).messages.catchUp(opts);
|
|
4376
|
+
setResult(r);
|
|
4377
|
+
return r;
|
|
4378
|
+
} catch (err) {
|
|
4379
|
+
setError(err);
|
|
4380
|
+
return null;
|
|
4381
|
+
} finally {
|
|
4382
|
+
setLoading(false);
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4385
|
+
};
|
|
4386
|
+
}
|
|
4387
|
+
function useTranslation(messageId, language) {
|
|
4388
|
+
const chat = usePoolse();
|
|
4389
|
+
const [translation, setTranslation] = react.useState(null);
|
|
4390
|
+
const [loading, setLoading] = react.useState(false);
|
|
4391
|
+
const [error, setError] = react.useState(null);
|
|
4392
|
+
react.useEffect(() => setTranslation(null), [messageId, language]);
|
|
4393
|
+
return {
|
|
4394
|
+
translation,
|
|
4395
|
+
loading,
|
|
4396
|
+
error,
|
|
4397
|
+
reset: () => setTranslation(null),
|
|
4398
|
+
translate: async () => {
|
|
4399
|
+
setLoading(true);
|
|
4400
|
+
setError(null);
|
|
4401
|
+
try {
|
|
4402
|
+
setTranslation(await chat.messages.one(messageId).translate(language));
|
|
4403
|
+
} catch (err) {
|
|
4404
|
+
setError(err);
|
|
4405
|
+
} finally {
|
|
4406
|
+
setLoading(false);
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
function useScheduledMessages(conversationId) {
|
|
4412
|
+
const chat = usePoolse();
|
|
4413
|
+
const [scheduled, setScheduled] = react.useState([]);
|
|
4414
|
+
const [loading, setLoading] = react.useState(true);
|
|
4415
|
+
const [error, setError] = react.useState(null);
|
|
4416
|
+
const refresh = react.useCallback(async () => {
|
|
4417
|
+
try {
|
|
4418
|
+
setScheduled(
|
|
4419
|
+
await chat.scheduledMessages.list(
|
|
4420
|
+
conversationId ? { conversation_id: conversationId } : {}
|
|
4421
|
+
)
|
|
4422
|
+
);
|
|
4423
|
+
setError(null);
|
|
4424
|
+
} catch (err) {
|
|
4425
|
+
setError(err);
|
|
4426
|
+
} finally {
|
|
4427
|
+
setLoading(false);
|
|
4428
|
+
}
|
|
4429
|
+
}, [chat, conversationId]);
|
|
4430
|
+
react.useEffect(() => {
|
|
4431
|
+
void refresh();
|
|
4432
|
+
const me = chat.me.peek()?.id;
|
|
4433
|
+
if (!me) return;
|
|
4434
|
+
return chat.realtime.user(me).onScheduledMessage(() => void refresh());
|
|
4435
|
+
}, [chat, refresh]);
|
|
4436
|
+
return {
|
|
4437
|
+
scheduled,
|
|
4438
|
+
loading,
|
|
4439
|
+
error,
|
|
4440
|
+
refresh,
|
|
4441
|
+
schedule: async (cid, req) => {
|
|
4442
|
+
const s = await chat.conversations.one(cid).messages.schedule(req);
|
|
4443
|
+
await refresh();
|
|
4444
|
+
return s;
|
|
4445
|
+
},
|
|
4446
|
+
cancel: async (id) => {
|
|
4447
|
+
setScheduled((l) => l.filter((s) => s.id !== id));
|
|
4448
|
+
await chat.scheduledMessages.cancel(id);
|
|
4449
|
+
},
|
|
4450
|
+
sendNow: async (id) => {
|
|
4451
|
+
setScheduled((l) => l.filter((s) => s.id !== id));
|
|
4452
|
+
await chat.scheduledMessages.sendNow(id);
|
|
4453
|
+
},
|
|
4454
|
+
reschedule: async (id, sendAt) => {
|
|
4455
|
+
await chat.scheduledMessages.update(id, { send_at: sendAt });
|
|
4456
|
+
await refresh();
|
|
4457
|
+
}
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4460
|
+
function useFiles(conversationId, kind) {
|
|
4461
|
+
const chat = usePoolse();
|
|
4462
|
+
const [files, setFiles] = react.useState([]);
|
|
4463
|
+
const [cursor, setCursor] = react.useState(null);
|
|
4464
|
+
const [hasMore, setHasMore] = react.useState(false);
|
|
4465
|
+
const [loading, setLoading] = react.useState(true);
|
|
4466
|
+
const [error, setError] = react.useState(null);
|
|
4467
|
+
const load = react.useCallback(
|
|
4468
|
+
async (before) => {
|
|
4469
|
+
setLoading(true);
|
|
4470
|
+
try {
|
|
4471
|
+
const page = await chat.conversations.one(conversationId).messages.files({ ...kind ? { kind } : {}, ...before ? { before } : {} });
|
|
4472
|
+
setFiles((f) => before ? [...f, ...page.data] : page.data);
|
|
4473
|
+
setCursor(page.next_cursor);
|
|
4474
|
+
setHasMore(page.next_cursor !== null);
|
|
4475
|
+
setError(null);
|
|
4476
|
+
} catch (err) {
|
|
4477
|
+
setError(err);
|
|
4478
|
+
} finally {
|
|
4479
|
+
setLoading(false);
|
|
4480
|
+
}
|
|
4481
|
+
},
|
|
4482
|
+
[chat, conversationId, kind]
|
|
4483
|
+
);
|
|
4484
|
+
react.useEffect(() => {
|
|
4485
|
+
void load(null);
|
|
4486
|
+
const conv = chat.realtime.conversation(conversationId);
|
|
4487
|
+
return conv.onAttachmentProcessed((evt) => {
|
|
4488
|
+
if (kind && evt.attachment.kind !== kind) return;
|
|
4489
|
+
setFiles((f) => {
|
|
4490
|
+
const group = evt.attachment.version_group_id;
|
|
4491
|
+
const rest = f.filter(
|
|
4492
|
+
(a) => a.id !== evt.attachment.id && (!group || a.version_group_id !== group)
|
|
4493
|
+
);
|
|
4494
|
+
return [evt.attachment, ...rest];
|
|
4495
|
+
});
|
|
4496
|
+
});
|
|
4497
|
+
}, [chat, conversationId, kind, load]);
|
|
4498
|
+
return {
|
|
4499
|
+
files,
|
|
4500
|
+
loading,
|
|
4501
|
+
error,
|
|
4502
|
+
hasMore,
|
|
4503
|
+
loadMore: async () => {
|
|
4504
|
+
if (cursor) await load(cursor);
|
|
4505
|
+
}
|
|
4506
|
+
};
|
|
4507
|
+
}
|
|
4508
|
+
var NAME = /^[a-z0-9_+-]{1,32}$/;
|
|
4509
|
+
function customEmojiToken(name) {
|
|
4510
|
+
return `:${name}:`;
|
|
4511
|
+
}
|
|
4512
|
+
function parseCustomEmojiToken(token) {
|
|
4513
|
+
const m = /^:([a-z0-9_+-]{1,32}):$/.exec(token);
|
|
4514
|
+
return m ? m[1] : null;
|
|
4515
|
+
}
|
|
4516
|
+
function findCustomEmoji(token, set) {
|
|
4517
|
+
const name = parseCustomEmojiToken(token);
|
|
4518
|
+
if (!name || !set) return null;
|
|
4519
|
+
return set.find((e) => e.name === name) ?? null;
|
|
4520
|
+
}
|
|
4521
|
+
function searchCustomEmoji(set, query) {
|
|
4522
|
+
const words = query.toLowerCase().replace(/:/g, " ").split(/\s+/).filter(Boolean);
|
|
4523
|
+
if (words.length === 0) return [...set];
|
|
4524
|
+
const hits = set.filter((e) => NAME.test(e.name) && words.every((w) => e.name.includes(w)));
|
|
4525
|
+
return hits.sort(
|
|
4526
|
+
(a, b) => Number(!a.name.startsWith(words[0])) - Number(!b.name.startsWith(words[0])) || a.name.localeCompare(b.name)
|
|
4527
|
+
);
|
|
4528
|
+
}
|
|
4529
|
+
var CustomEmojiContext = react.createContext([]);
|
|
4530
|
+
function CustomEmojiProvider({
|
|
4531
|
+
emoji,
|
|
4532
|
+
children
|
|
4533
|
+
}) {
|
|
4534
|
+
return react.createElement(CustomEmojiContext.Provider, { value: emoji }, children);
|
|
4535
|
+
}
|
|
4536
|
+
function useCustomEmoji() {
|
|
4537
|
+
return react.useContext(CustomEmojiContext);
|
|
4538
|
+
}
|
|
4539
|
+
|
|
4540
|
+
Object.defineProperty(exports, "APPROVAL_REASON_MAX", {
|
|
4541
|
+
enumerable: true,
|
|
4542
|
+
get: function () { return sdk.APPROVAL_REASON_MAX; }
|
|
4543
|
+
});
|
|
4544
|
+
Object.defineProperty(exports, "ASK_QUESTION_MAX", {
|
|
4545
|
+
enumerable: true,
|
|
4546
|
+
get: function () { return sdk.ASK_QUESTION_MAX; }
|
|
4547
|
+
});
|
|
4548
|
+
Object.defineProperty(exports, "ApiError", {
|
|
4549
|
+
enumerable: true,
|
|
4550
|
+
get: function () { return sdk.ApiError; }
|
|
4551
|
+
});
|
|
4552
|
+
Object.defineProperty(exports, "AuthError", {
|
|
4553
|
+
enumerable: true,
|
|
4554
|
+
get: function () { return sdk.AuthError; }
|
|
4555
|
+
});
|
|
4556
|
+
Object.defineProperty(exports, "BRIEF_RULE_MAX", {
|
|
4557
|
+
enumerable: true,
|
|
4558
|
+
get: function () { return sdk.BRIEF_RULE_MAX; }
|
|
4559
|
+
});
|
|
4560
|
+
Object.defineProperty(exports, "BRIEF_TEXT_MAX", {
|
|
4561
|
+
enumerable: true,
|
|
4562
|
+
get: function () { return sdk.BRIEF_TEXT_MAX; }
|
|
4563
|
+
});
|
|
4564
|
+
Object.defineProperty(exports, "DEFAULT_DOC_LIMITS", {
|
|
4565
|
+
enumerable: true,
|
|
4566
|
+
get: function () { return sdk.DEFAULT_DOC_LIMITS; }
|
|
4567
|
+
});
|
|
4568
|
+
Object.defineProperty(exports, "DocChannel", {
|
|
4569
|
+
enumerable: true,
|
|
4570
|
+
get: function () { return sdk.DocChannel; }
|
|
4571
|
+
});
|
|
4572
|
+
Object.defineProperty(exports, "DocPushError", {
|
|
4573
|
+
enumerable: true,
|
|
4574
|
+
get: function () { return sdk.DocPushError; }
|
|
4575
|
+
});
|
|
4576
|
+
Object.defineProperty(exports, "ESCALATION_ANSWER_MAX", {
|
|
4577
|
+
enumerable: true,
|
|
4578
|
+
get: function () { return sdk.ESCALATION_ANSWER_MAX; }
|
|
4579
|
+
});
|
|
4580
|
+
Object.defineProperty(exports, "MessageDiscardedError", {
|
|
4581
|
+
enumerable: true,
|
|
4582
|
+
get: function () { return sdk.MessageDiscardedError; }
|
|
4583
|
+
});
|
|
4584
|
+
Object.defineProperty(exports, "MessageQueuedError", {
|
|
4585
|
+
enumerable: true,
|
|
4586
|
+
get: function () { return sdk.MessageQueuedError; }
|
|
4587
|
+
});
|
|
4588
|
+
Object.defineProperty(exports, "NetworkError", {
|
|
4589
|
+
enumerable: true,
|
|
4590
|
+
get: function () { return sdk.NetworkError; }
|
|
4591
|
+
});
|
|
4592
|
+
Object.defineProperty(exports, "PLAYBACK_RATES", {
|
|
4593
|
+
enumerable: true,
|
|
4594
|
+
get: function () { return sdk.PLAYBACK_RATES; }
|
|
4595
|
+
});
|
|
4596
|
+
Object.defineProperty(exports, "POOLSE_SERVICE_IDENTITY_PREFIX", {
|
|
4597
|
+
enumerable: true,
|
|
4598
|
+
get: function () { return sdk.POOLSE_SERVICE_IDENTITY_PREFIX; }
|
|
4599
|
+
});
|
|
4600
|
+
Object.defineProperty(exports, "Poolse", {
|
|
4601
|
+
enumerable: true,
|
|
4602
|
+
get: function () { return sdk.Poolse; }
|
|
4603
|
+
});
|
|
4604
|
+
Object.defineProperty(exports, "PoolseError", {
|
|
4605
|
+
enumerable: true,
|
|
4606
|
+
get: function () { return sdk.PoolseError; }
|
|
4607
|
+
});
|
|
4608
|
+
Object.defineProperty(exports, "RateLimitedError", {
|
|
4609
|
+
enumerable: true,
|
|
4610
|
+
get: function () { return sdk.RateLimitedError; }
|
|
4611
|
+
});
|
|
4612
|
+
Object.defineProperty(exports, "activeSegmentIndex", {
|
|
4613
|
+
enumerable: true,
|
|
4614
|
+
get: function () { return sdk.activeSegmentIndex; }
|
|
4615
|
+
});
|
|
4616
|
+
Object.defineProperty(exports, "agentFromWire", {
|
|
4617
|
+
enumerable: true,
|
|
4618
|
+
get: function () { return sdk.agentFromWire; }
|
|
4619
|
+
});
|
|
4620
|
+
Object.defineProperty(exports, "agentMetaOf", {
|
|
4621
|
+
enumerable: true,
|
|
4622
|
+
get: function () { return sdk.agentMetaOf; }
|
|
4623
|
+
});
|
|
4624
|
+
Object.defineProperty(exports, "applyLiveSegment", {
|
|
4625
|
+
enumerable: true,
|
|
4626
|
+
get: function () { return sdk.applyLiveSegment; }
|
|
4627
|
+
});
|
|
4628
|
+
Object.defineProperty(exports, "approvalErrorMessage", {
|
|
4629
|
+
enumerable: true,
|
|
4630
|
+
get: function () { return sdk.approvalErrorMessage; }
|
|
4631
|
+
});
|
|
4632
|
+
Object.defineProperty(exports, "approvalFromWire", {
|
|
4633
|
+
enumerable: true,
|
|
4634
|
+
get: function () { return sdk.approvalFromWire; }
|
|
4635
|
+
});
|
|
4636
|
+
Object.defineProperty(exports, "approvalIdOf", {
|
|
4637
|
+
enumerable: true,
|
|
4638
|
+
get: function () { return sdk.approvalIdOf; }
|
|
4639
|
+
});
|
|
4640
|
+
Object.defineProperty(exports, "approvalStatusLabel", {
|
|
4641
|
+
enumerable: true,
|
|
4642
|
+
get: function () { return sdk.approvalStatusLabel; }
|
|
4643
|
+
});
|
|
4644
|
+
Object.defineProperty(exports, "callAgentModeLabel", {
|
|
4645
|
+
enumerable: true,
|
|
4646
|
+
get: function () { return sdk.callAgentModeLabel; }
|
|
4647
|
+
});
|
|
4648
|
+
Object.defineProperty(exports, "callAgentOfParticipant", {
|
|
4649
|
+
enumerable: true,
|
|
4650
|
+
get: function () { return sdk.callAgentOfParticipant; }
|
|
4651
|
+
});
|
|
4652
|
+
Object.defineProperty(exports, "callAgentStateLabel", {
|
|
4653
|
+
enumerable: true,
|
|
4654
|
+
get: function () { return sdk.callAgentStateLabel; }
|
|
4655
|
+
});
|
|
4656
|
+
Object.defineProperty(exports, "callAgentStateOf", {
|
|
4657
|
+
enumerable: true,
|
|
4658
|
+
get: function () { return sdk.callAgentStateOf; }
|
|
4659
|
+
});
|
|
4660
|
+
Object.defineProperty(exports, "callLogDisplayFor", {
|
|
4661
|
+
enumerable: true,
|
|
4662
|
+
get: function () { return sdk.callLogDisplayFor; }
|
|
4663
|
+
});
|
|
4664
|
+
Object.defineProperty(exports, "captureErrorMessage", {
|
|
4665
|
+
enumerable: true,
|
|
4666
|
+
get: function () { return sdk.captureErrorMessage; }
|
|
4667
|
+
});
|
|
2643
4668
|
Object.defineProperty(exports, "captureLabel", {
|
|
2644
4669
|
enumerable: true,
|
|
2645
4670
|
get: function () { return sdk.captureLabel; }
|
|
2646
4671
|
});
|
|
4672
|
+
Object.defineProperty(exports, "chapterIndexAt", {
|
|
4673
|
+
enumerable: true,
|
|
4674
|
+
get: function () { return sdk.chapterIndexAt; }
|
|
4675
|
+
});
|
|
4676
|
+
Object.defineProperty(exports, "chaptersOf", {
|
|
4677
|
+
enumerable: true,
|
|
4678
|
+
get: function () { return sdk.chaptersOf; }
|
|
4679
|
+
});
|
|
4680
|
+
Object.defineProperty(exports, "citationLabel", {
|
|
4681
|
+
enumerable: true,
|
|
4682
|
+
get: function () { return sdk.citationLabel; }
|
|
4683
|
+
});
|
|
4684
|
+
Object.defineProperty(exports, "citationsOf", {
|
|
4685
|
+
enumerable: true,
|
|
4686
|
+
get: function () { return sdk.citationsOf; }
|
|
4687
|
+
});
|
|
4688
|
+
Object.defineProperty(exports, "clipFromWire", {
|
|
4689
|
+
enumerable: true,
|
|
4690
|
+
get: function () { return sdk.clipFromWire; }
|
|
4691
|
+
});
|
|
4692
|
+
Object.defineProperty(exports, "clipOf", {
|
|
4693
|
+
enumerable: true,
|
|
4694
|
+
get: function () { return sdk.clipOf; }
|
|
4695
|
+
});
|
|
2647
4696
|
Object.defineProperty(exports, "createIndexedDbStorage", {
|
|
2648
4697
|
enumerable: true,
|
|
2649
4698
|
get: function () { return sdk.createIndexedDbStorage; }
|
|
@@ -2656,6 +4705,14 @@ Object.defineProperty(exports, "describeRecordingNotice", {
|
|
|
2656
4705
|
enumerable: true,
|
|
2657
4706
|
get: function () { return sdk.describeRecordingNotice; }
|
|
2658
4707
|
});
|
|
4708
|
+
Object.defineProperty(exports, "escalationErrorMessage", {
|
|
4709
|
+
enumerable: true,
|
|
4710
|
+
get: function () { return sdk.escalationErrorMessage; }
|
|
4711
|
+
});
|
|
4712
|
+
Object.defineProperty(exports, "escalationStatusLabel", {
|
|
4713
|
+
enumerable: true,
|
|
4714
|
+
get: function () { return sdk.escalationStatusLabel; }
|
|
4715
|
+
});
|
|
2659
4716
|
Object.defineProperty(exports, "findInText", {
|
|
2660
4717
|
enumerable: true,
|
|
2661
4718
|
get: function () { return sdk.findInText; }
|
|
@@ -2668,10 +4725,26 @@ Object.defineProperty(exports, "formatCallLogPreview", {
|
|
|
2668
4725
|
enumerable: true,
|
|
2669
4726
|
get: function () { return sdk.formatCallLogPreview; }
|
|
2670
4727
|
});
|
|
4728
|
+
Object.defineProperty(exports, "formatCallSummaryPreview", {
|
|
4729
|
+
enumerable: true,
|
|
4730
|
+
get: function () { return sdk.formatCallSummaryPreview; }
|
|
4731
|
+
});
|
|
4732
|
+
Object.defineProperty(exports, "formatClock", {
|
|
4733
|
+
enumerable: true,
|
|
4734
|
+
get: function () { return sdk.formatClock; }
|
|
4735
|
+
});
|
|
4736
|
+
Object.defineProperty(exports, "formatDue", {
|
|
4737
|
+
enumerable: true,
|
|
4738
|
+
get: function () { return sdk.formatDue; }
|
|
4739
|
+
});
|
|
2671
4740
|
Object.defineProperty(exports, "formatRecordingNoticePreview", {
|
|
2672
4741
|
enumerable: true,
|
|
2673
4742
|
get: function () { return sdk.formatRecordingNoticePreview; }
|
|
2674
4743
|
});
|
|
4744
|
+
Object.defineProperty(exports, "formatTimeRange", {
|
|
4745
|
+
enumerable: true,
|
|
4746
|
+
get: function () { return sdk.formatTimeRange; }
|
|
4747
|
+
});
|
|
2675
4748
|
Object.defineProperty(exports, "groupTranscript", {
|
|
2676
4749
|
enumerable: true,
|
|
2677
4750
|
get: function () { return sdk.groupTranscript; }
|
|
@@ -2692,6 +4765,10 @@ Object.defineProperty(exports, "isTombstone", {
|
|
|
2692
4765
|
enumerable: true,
|
|
2693
4766
|
get: function () { return sdk.isTombstone; }
|
|
2694
4767
|
});
|
|
4768
|
+
Object.defineProperty(exports, "meetingsErrorMessage", {
|
|
4769
|
+
enumerable: true,
|
|
4770
|
+
get: function () { return sdk.meetingsErrorMessage; }
|
|
4771
|
+
});
|
|
2695
4772
|
Object.defineProperty(exports, "memoryStorage", {
|
|
2696
4773
|
enumerable: true,
|
|
2697
4774
|
get: function () { return sdk.memoryStorage; }
|
|
@@ -2700,6 +4777,14 @@ Object.defineProperty(exports, "mergeMessage", {
|
|
|
2700
4777
|
enumerable: true,
|
|
2701
4778
|
get: function () { return sdk.mergeMessage; }
|
|
2702
4779
|
});
|
|
4780
|
+
Object.defineProperty(exports, "messageAgent", {
|
|
4781
|
+
enumerable: true,
|
|
4782
|
+
get: function () { return sdk.messageAgent; }
|
|
4783
|
+
});
|
|
4784
|
+
Object.defineProperty(exports, "momentOf", {
|
|
4785
|
+
enumerable: true,
|
|
4786
|
+
get: function () { return sdk.momentOf; }
|
|
4787
|
+
});
|
|
2703
4788
|
Object.defineProperty(exports, "parseCallLog", {
|
|
2704
4789
|
enumerable: true,
|
|
2705
4790
|
get: function () { return sdk.parseCallLog; }
|
|
@@ -2708,6 +4793,10 @@ Object.defineProperty(exports, "parseCallLogBody", {
|
|
|
2708
4793
|
enumerable: true,
|
|
2709
4794
|
get: function () { return sdk.parseCallLogBody; }
|
|
2710
4795
|
});
|
|
4796
|
+
Object.defineProperty(exports, "parseCallSummary", {
|
|
4797
|
+
enumerable: true,
|
|
4798
|
+
get: function () { return sdk.parseCallSummary; }
|
|
4799
|
+
});
|
|
2711
4800
|
Object.defineProperty(exports, "parseRecordingNotice", {
|
|
2712
4801
|
enumerable: true,
|
|
2713
4802
|
get: function () { return sdk.parseRecordingNotice; }
|
|
@@ -2720,56 +4809,150 @@ Object.defineProperty(exports, "recordingNoticeDisplayFor", {
|
|
|
2720
4809
|
enumerable: true,
|
|
2721
4810
|
get: function () { return sdk.recordingNoticeDisplayFor; }
|
|
2722
4811
|
});
|
|
4812
|
+
Object.defineProperty(exports, "silencesFromSegments", {
|
|
4813
|
+
enumerable: true,
|
|
4814
|
+
get: function () { return sdk.silencesFromSegments; }
|
|
4815
|
+
});
|
|
4816
|
+
Object.defineProperty(exports, "silencesOf", {
|
|
4817
|
+
enumerable: true,
|
|
4818
|
+
get: function () { return sdk.silencesOf; }
|
|
4819
|
+
});
|
|
4820
|
+
Object.defineProperty(exports, "skipSilenceTarget", {
|
|
4821
|
+
enumerable: true,
|
|
4822
|
+
get: function () { return sdk.skipSilenceTarget; }
|
|
4823
|
+
});
|
|
2723
4824
|
Object.defineProperty(exports, "speakerName", {
|
|
2724
4825
|
enumerable: true,
|
|
2725
4826
|
get: function () { return sdk.speakerName; }
|
|
2726
4827
|
});
|
|
4828
|
+
Object.defineProperty(exports, "summaryFromWire", {
|
|
4829
|
+
enumerable: true,
|
|
4830
|
+
get: function () { return sdk.summaryFromWire; }
|
|
4831
|
+
});
|
|
4832
|
+
Object.defineProperty(exports, "summaryStatusText", {
|
|
4833
|
+
enumerable: true,
|
|
4834
|
+
get: function () { return sdk.summaryStatusText; }
|
|
4835
|
+
});
|
|
4836
|
+
Object.defineProperty(exports, "summaryStyleLabel", {
|
|
4837
|
+
enumerable: true,
|
|
4838
|
+
get: function () { return sdk.summaryStyleLabel; }
|
|
4839
|
+
});
|
|
2727
4840
|
Object.defineProperty(exports, "toTombstone", {
|
|
2728
4841
|
enumerable: true,
|
|
2729
4842
|
get: function () { return sdk.toTombstone; }
|
|
2730
4843
|
});
|
|
4844
|
+
Object.defineProperty(exports, "toolLabel", {
|
|
4845
|
+
enumerable: true,
|
|
4846
|
+
get: function () { return sdk.toolLabel; }
|
|
4847
|
+
});
|
|
4848
|
+
Object.defineProperty(exports, "whisperErrorMessage", {
|
|
4849
|
+
enumerable: true,
|
|
4850
|
+
get: function () { return sdk.whisperErrorMessage; }
|
|
4851
|
+
});
|
|
4852
|
+
Object.defineProperty(exports, "whisperHintKindLabel", {
|
|
4853
|
+
enumerable: true,
|
|
4854
|
+
get: function () { return sdk.whisperHintKindLabel; }
|
|
4855
|
+
});
|
|
4856
|
+
exports.CustomEmojiProvider = CustomEmojiProvider;
|
|
2731
4857
|
exports.EDIT_WINDOW_MS = EDIT_WINDOW_MS;
|
|
4858
|
+
exports.FORMAT_ACTIONS = FORMAT_ACTIONS;
|
|
4859
|
+
exports.MESSAGE_PLAYBACK_RATES = MESSAGE_PLAYBACK_RATES;
|
|
2732
4860
|
exports.PoolseProvider = PoolseProvider;
|
|
2733
4861
|
exports.applyCaptureEvent = applyCaptureEvent;
|
|
4862
|
+
exports.applyFormat = applyFormat;
|
|
4863
|
+
exports.applySlashCommand = applySlashCommand;
|
|
2734
4864
|
exports.canEditOwnMessage = canEditOwnMessage;
|
|
2735
4865
|
exports.computeGroupPosition = computeGroupPosition;
|
|
4866
|
+
exports.customEmojiToken = customEmojiToken;
|
|
2736
4867
|
exports.filterConversations = filterConversations;
|
|
4868
|
+
exports.filterSlashCommands = filterSlashCommands;
|
|
4869
|
+
exports.findCustomEmoji = findCustomEmoji;
|
|
2737
4870
|
exports.formatDayLabel = formatDayLabel;
|
|
4871
|
+
exports.formatForShortcut = formatForShortcut;
|
|
4872
|
+
exports.mentionGroupMeta = mentionGroupMeta;
|
|
4873
|
+
exports.nextPlaybackRate = nextPlaybackRate;
|
|
2738
4874
|
exports.orderUnread = orderUnread;
|
|
4875
|
+
exports.parseCustomEmojiToken = parseCustomEmojiToken;
|
|
4876
|
+
exports.parseSlashCommand = parseSlashCommand;
|
|
4877
|
+
exports.playbackRateLabel = playbackRateLabel;
|
|
4878
|
+
exports.rankMentionGroups = rankMentionGroups;
|
|
4879
|
+
exports.readDlpError = readDlpError;
|
|
2739
4880
|
exports.receiptsOf = receiptsOf;
|
|
2740
4881
|
exports.sameDay = sameDay;
|
|
2741
4882
|
exports.sameGroup = sameGroup;
|
|
4883
|
+
exports.searchCustomEmoji = searchCustomEmoji;
|
|
4884
|
+
exports.slashCommandsFromWorkspace = slashCommandsFromWorkspace;
|
|
4885
|
+
exports.slashQuery = slashQuery;
|
|
4886
|
+
exports.useAgenda = useAgenda;
|
|
4887
|
+
exports.useAgent = useAgent;
|
|
4888
|
+
exports.useAgentBrief = useAgentBrief;
|
|
4889
|
+
exports.useAgents = useAgents;
|
|
2742
4890
|
exports.useAppEvent = useAppEvent;
|
|
4891
|
+
exports.useApproval = useApproval;
|
|
4892
|
+
exports.useApprovals = useApprovals;
|
|
4893
|
+
exports.useAskMeetings = useAskMeetings;
|
|
2743
4894
|
exports.useAttachmentUpload = useAttachmentUpload;
|
|
2744
4895
|
exports.useAttachmentUrl = useAttachmentUrl;
|
|
4896
|
+
exports.useBreakouts = useBreakouts;
|
|
4897
|
+
exports.useCallAgents = useCallAgents;
|
|
4898
|
+
exports.useCallMeeting = useCallMeeting;
|
|
4899
|
+
exports.useCallQuality = useCallQuality;
|
|
4900
|
+
exports.useCallReactions = useCallReactions;
|
|
2745
4901
|
exports.useCallRoom = useCallRoom;
|
|
4902
|
+
exports.useCallSummary = useCallSummary;
|
|
4903
|
+
exports.useCaptions = useCaptions;
|
|
4904
|
+
exports.useCatchUp = useCatchUp;
|
|
2746
4905
|
exports.useClientTimings = useClientTimings;
|
|
4906
|
+
exports.useClip = useClip;
|
|
2747
4907
|
exports.useConversation = useConversation;
|
|
4908
|
+
exports.useConversationAgents = useConversationAgents;
|
|
2748
4909
|
exports.useConversationPresence = useConversationPresence;
|
|
2749
4910
|
exports.useConversations = useConversations;
|
|
4911
|
+
exports.useCustomEmoji = useCustomEmoji;
|
|
4912
|
+
exports.useEscalations = useEscalations;
|
|
4913
|
+
exports.useFiles = useFiles;
|
|
4914
|
+
exports.useFollowups = useFollowups;
|
|
2750
4915
|
exports.useLiveCall = useLiveCall;
|
|
2751
4916
|
exports.useLiveTranscript = useLiveTranscript;
|
|
4917
|
+
exports.useLobby = useLobby;
|
|
2752
4918
|
exports.useMe = useMe;
|
|
2753
4919
|
exports.useMembers = useMembers;
|
|
4920
|
+
exports.useMemory = useMemory;
|
|
2754
4921
|
exports.useMessageStreams = useMessageStreams;
|
|
2755
4922
|
exports.useMessages = useMessages;
|
|
4923
|
+
exports.useMoments = useMoments;
|
|
4924
|
+
exports.useOptionalPoolse = useOptionalPoolse;
|
|
2756
4925
|
exports.useOutbox = useOutbox;
|
|
4926
|
+
exports.usePins = usePins;
|
|
4927
|
+
exports.usePoll = usePoll;
|
|
2757
4928
|
exports.usePoolse = usePoolse;
|
|
2758
4929
|
exports.usePresence = usePresence;
|
|
2759
4930
|
exports.usePresenceMany = usePresenceMany;
|
|
4931
|
+
exports.useQuestions = useQuestions;
|
|
2760
4932
|
exports.useReactions = useReactions;
|
|
2761
4933
|
exports.useReadReceipts = useReadReceipts;
|
|
2762
4934
|
exports.useRealtimeStatus = useRealtimeStatus;
|
|
2763
4935
|
exports.useRecording = useRecording;
|
|
4936
|
+
exports.useRecordingPlayback = useRecordingPlayback;
|
|
4937
|
+
exports.useRecordingUrl = useRecordingUrl;
|
|
2764
4938
|
exports.useRecordings = useRecordings;
|
|
2765
4939
|
exports.useRoom = useRoom;
|
|
4940
|
+
exports.useRoomPresence = useRoomPresence;
|
|
4941
|
+
exports.useScheduledMessages = useScheduledMessages;
|
|
4942
|
+
exports.useScreenAnnotations = useScreenAnnotations;
|
|
4943
|
+
exports.useStage = useStage;
|
|
2766
4944
|
exports.useThread = useThread;
|
|
4945
|
+
exports.useThreadFollow = useThreadFollow;
|
|
2767
4946
|
exports.useTranscript = useTranscript;
|
|
2768
4947
|
exports.useTranscripts = useTranscripts;
|
|
4948
|
+
exports.useTranslation = useTranslation;
|
|
2769
4949
|
exports.useTyping = useTyping;
|
|
2770
4950
|
exports.useUnreadQueue = useUnreadQueue;
|
|
2771
4951
|
exports.useUnreadTotals = useUnreadTotals;
|
|
2772
4952
|
exports.useUser = useUser;
|
|
2773
4953
|
exports.useUserPresence = useUserPresence;
|
|
4954
|
+
exports.useWhisper = useWhisper;
|
|
4955
|
+
exports.useWhiteboard = useWhiteboard;
|
|
4956
|
+
exports.waveformBars = waveformBars;
|
|
2774
4957
|
//# sourceMappingURL=index.cjs.map
|
|
2775
4958
|
//# sourceMappingURL=index.cjs.map
|