Добавить смену профилей, пока не работает

This commit is contained in:
AidarKC
2026-09-03 12:51:46 +04:00
parent ebc9143593
commit e0295eebde
8 changed files with 227 additions and 43 deletions
+15 -9
View File
@@ -1,6 +1,8 @@
import { renderHeader } from '../components/header.js';
import {
authService,
cancelAddProfileLogin,
consumeAuthReturnPage,
authorizeSession,
refreshSessions,
resetRegistrationFlow,
@@ -103,7 +105,12 @@ export function render({ navigate }) {
cancelButton.className = 'ghost-btn';
cancelButton.type = 'button';
cancelButton.textContent = 'Отмена';
cancelButton.addEventListener('click', () => {
cancelButton.addEventListener('click', async () => {
if (state.authReturnHash === '/profiles') {
await cancelAddProfileLogin();
navigate('profiles-view');
return;
}
resetRegistrationFlow();
navigate('start-view');
});
@@ -174,13 +181,7 @@ export function render({ navigate }) {
setAuthInfo(isLoginFlow
? `Ключи сохранены. Вы вошли как @${state.registrationDraft.login}. Далее откройте вкладку «Каналы».`
: `Ключи сохранены. Регистрация завершена для @${state.registrationDraft.login}. Далее откройте вкладку «Каналы».`);
const nextHash = String(state.authReturnHash || '').trim();
state.authReturnHash = '';
if (nextHash.startsWith('/')) {
navigate(nextHash.slice(1));
} else {
navigate('profile-view');
}
navigate(consumeAuthReturnPage('profile-view'));
} catch (error) {
const message = toUserMessage(error, 'Не удалось сохранить ключи на устройстве.');
setAuthError(message);
@@ -196,7 +197,12 @@ export function render({ navigate }) {
title: 'Сохранение ключей',
leftAction: {
label: '←',
onClick: () => {
onClick: async () => {
if (state.authReturnHash === '/profiles') {
await cancelAddProfileLogin();
navigate('profiles-view');
return;
}
resetRegistrationFlow();
navigate('start-view');
},