Add WS push events, PWA/FCM scaffolding, and direct messaging MVP

This commit is contained in:
ai5590
2026-04-04 18:10:25 +03:00
parent cf5460c5c7
commit 32c046233b
40 changed files with 1300 additions and 114 deletions
+16
View File
@@ -41,6 +41,8 @@ function createInitialState({ withStoredSession = true } = {}) {
const storedSession = withStoredSession ? loadStoredSession() : null;
return {
chats: clone(chatMessages),
contacts: [],
incomingDedup: {},
notificationsTab: 'replies',
pageLabelCollapsed: false,
session: {
@@ -121,6 +123,20 @@ export function addChatMessage(chatId, text) {
getChatMessages(chatId).push({ from: 'out', text: message });
}
export function addIncomingMessage(chatId, text, messageId = '') {
const msg = text?.trim();
if (!msg) return false;
if (messageId && state.incomingDedup[messageId]) return false;
if (messageId) state.incomingDedup[messageId] = true;
getChatMessages(chatId).push({ from: 'in', text: msg, messageId });
return true;
}
export function setContacts(list) {
state.contacts = Array.isArray(list) ? [...list] : [];
}
export function togglePageLabel() {
state.pageLabelCollapsed = !state.pageLabelCollapsed;
}