SHA256
fix(ui): обработка устаревшей сессии и корректировка индикаторов соединения
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { renderHeader } from '../components/header.js';
|
||||
import { directMessages } from '../mock-data.js';
|
||||
import { getChatMessages, setContacts, state } from '../state.js';
|
||||
import {
|
||||
getChatMessages,
|
||||
isSessionInvalidError,
|
||||
setContacts,
|
||||
state,
|
||||
terminateCurrentSession,
|
||||
} from '../state.js';
|
||||
import { loadCurrentRelations } from '../services/user-connections.js';
|
||||
|
||||
export const pageMeta = { id: 'messages-list', title: 'Личные сообщения' };
|
||||
@@ -103,6 +109,37 @@ export function render({ navigate }) {
|
||||
status.className = 'status-line is-available';
|
||||
status.textContent = `Загружено диалогов: ${rows.length}`;
|
||||
} catch (error) {
|
||||
if (isSessionInvalidError(error)) {
|
||||
list.innerHTML = '';
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = 'Сессия устарела.';
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card stack';
|
||||
|
||||
const title = document.createElement('strong');
|
||||
title.textContent = 'Сессия устарела';
|
||||
|
||||
const details = document.createElement('p');
|
||||
details.className = 'meta-muted';
|
||||
details.textContent = 'Ваша сессия больше не действует. Авторизуйтесь заново.';
|
||||
|
||||
const okBtn = document.createElement('button');
|
||||
okBtn.type = 'button';
|
||||
okBtn.className = 'primary-btn';
|
||||
okBtn.textContent = 'ОК';
|
||||
okBtn.addEventListener('click', async () => {
|
||||
await terminateCurrentSession({
|
||||
infoMessage: 'Ваша сессия устарела. Выполните вход заново.',
|
||||
});
|
||||
navigate('start-view');
|
||||
});
|
||||
|
||||
card.append(title, details, okBtn);
|
||||
list.append(card);
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = '';
|
||||
const fail = document.createElement('div');
|
||||
fail.className = 'card meta-muted';
|
||||
|
||||
Reference in New Issue
Block a user