SHA256
UI: нормальное закрытие сессий и сортировка устройств
This commit is contained in:
+22
-16
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user