UI: нормальное закрытие сессий и сортировка устройств

This commit is contained in:
AidarKC
2026-06-16 10:36:43 +04:00
parent 41d199e24a
commit 5c155ef503
8 changed files with 133 additions and 40 deletions
+22 -16
View File
@@ -749,7 +749,27 @@ function resetStateForSignedOut() {
state.messageReactions = next.messageReactions;
}
export async function terminateCurrentSession({ infoMessage = '' } = {}) {
async function tryCloseCurrentSessionOnServer() {
const currentSessionId = String(state.session.sessionId || '').trim();
if (!state.session.isAuthorized || !currentSessionId) return;
try {
await authService.closeSession(currentSessionId);
} catch (error) {
addAppLogEntry({
level: 'warn',
source: 'session',
message: 'Не удалось завершить текущую сессию на сервере',
details: { sessionId: currentSessionId, error: error?.message || 'unknown' },
});
}
}
export async function terminateCurrentSession({ infoMessage = '', closeServerSession = false } = {}) {
if (closeServerSession) {
await tryCloseCurrentSessionOnServer();
}
clearStoredSession();
resetStateForSignedOut();
await clearStoredMessages().catch(() => {});
@@ -768,21 +788,7 @@ export async function terminateCurrentSession({ infoMessage = '' } = {}) {
}
export async function closeCurrentSessionAndSignOut({ infoMessage = '' } = {}) {
const currentSessionId = String(state.session.sessionId || '').trim();
try {
if (state.session.isAuthorized && currentSessionId) {
await authService.closeSession(currentSessionId);
}
} catch (error) {
addAppLogEntry({
level: 'warn',
source: 'session',
message: 'Не удалось завершить текущую сессию на сервере',
details: { sessionId: currentSessionId, error: error?.message || 'unknown' },
});
}
await terminateCurrentSession({ infoMessage });
await terminateCurrentSession({ infoMessage, closeServerSession: true });
}
export function refreshRegistrationBalance() {