Add MVP call signaling API and browser call flow

This commit is contained in:
ai5590
2026-04-15 09:33:37 +03:00
parent 1ee2a1cf62
commit eaad476bf5
12 changed files with 665 additions and 2 deletions
+20 -2
View File
@@ -1,6 +1,7 @@
import { renderHeader } from '../components/header.js';
import { directMessages } from '../mock-data.js';
import { addChatMessage, getChatMessages, authService } from '../state.js';
import { startOutgoingCall, hangupActiveCall } from '../services/call-service.js';
export const pageMeta = { id: 'chat-view', title: 'Чат' };
@@ -33,10 +34,27 @@ export function render({ navigate, route }) {
leftAction: { label: '←', onClick: () => navigate('messages-list') },
rightActions: [{
label: 'Позвонить',
onClick: () => {
onClick: async () => {
const confirmed = window.confirm('Позвонить этому пользователю?');
if (!confirmed) return;
window.alert('Функция пока не реализована');
try {
await startOutgoingCall(chatId);
renderLog(log, chatId);
} catch (e) {
addChatMessage(chatId, `[call] Ошибка звонка: ${e.message || 'unknown'}`);
renderLog(log, chatId);
}
},
}, {
label: 'Сброс',
onClick: async () => {
try {
await hangupActiveCall();
renderLog(log, chatId);
} catch (e) {
addChatMessage(chatId, `[call] Ошибка сброса: ${e.message || 'unknown'}`);
renderLog(log, chatId);
}
},
}],
})