SHA256
Добавить ответы в DM и обновить UI чатов
This commit is contained in:
@@ -27,6 +27,7 @@ let toneFlip = false;
|
||||
const DEFAULT_ICE_SERVERS = Object.freeze([
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
]);
|
||||
const CALL_SUMMARY_MIN_TOTAL_MS = 5000;
|
||||
|
||||
function nowMs() {
|
||||
return Date.now();
|
||||
@@ -167,6 +168,8 @@ async function applyLocalOutgoingDmCopy(peerLogin, result) {
|
||||
|
||||
async function sendOutgoingCallSummaryDm(call, summaryCode) {
|
||||
if (!call || call.direction !== 'out' || !call.peerLogin) return;
|
||||
const totalMs = Math.max(0, nowMs() - Number(call.startedAtMs || nowMs()));
|
||||
if (totalMs < CALL_SUMMARY_MIN_TOTAL_MS) return;
|
||||
const text = buildOutgoingCallSummaryText(call, summaryCode);
|
||||
if (!text) return;
|
||||
const login = String(state?.session?.login || '').trim();
|
||||
|
||||
@@ -2,6 +2,7 @@ function defaultParsed(rawText = '') {
|
||||
const text = String(rawText || '');
|
||||
return {
|
||||
rawText: text,
|
||||
prefixText: '',
|
||||
visibleText: text,
|
||||
displayText: text,
|
||||
blocks: [],
|
||||
@@ -68,6 +69,12 @@ export function buildDmCallTechBlock({ status = '', durationSec = 0, reason = ''
|
||||
return `<SHiNE:call;v=1;status=failed;reason=${cleanReason || 'connect_failed'}>`;
|
||||
}
|
||||
|
||||
export function buildDmReplyTechBlock({ baseKey = '' } = {}) {
|
||||
const cleanBaseKey = String(baseKey || '').trim();
|
||||
if (!cleanBaseKey) return '';
|
||||
return `<SHiNE:reply;v=1;id=${cleanBaseKey}>`;
|
||||
}
|
||||
|
||||
export function parseDmTechBlocks(rawText = '') {
|
||||
const text = String(rawText || '');
|
||||
if (!text.startsWith('<SHiNE:')) return defaultParsed(text);
|
||||
@@ -127,6 +134,7 @@ export function parseDmTechBlocks(rawText = '') {
|
||||
const displayText = callSummary ? buildCallDisplayText(callSummary) : visibleText;
|
||||
return {
|
||||
rawText: text,
|
||||
prefixText: text.slice(0, cursor),
|
||||
visibleText,
|
||||
displayText,
|
||||
blocks,
|
||||
|
||||
Reference in New Issue
Block a user