Refine unread marker and reset registration flow

This commit is contained in:
AidarKC
2026-08-21 15:04:29 +04:00
parent fef7694b48
commit 0a4c31fb36
5 changed files with 33 additions and 6 deletions
+2 -2
View File
@@ -268,7 +268,7 @@ function scrollElementToViewportFraction(element, fraction = 1 / 3, smooth = fal
} }
function scrollChannelToUnreadLine(screen, smooth = false) { function scrollChannelToUnreadLine(screen, smooth = false) {
return scrollElementToViewportFraction(screen.querySelector('.channel-unread-line'), 1 / 3, smooth); return scrollElementToViewportFraction(screen.querySelector('.channel-unread-line'), 0.42, smooth);
} }
function createChannelReadTracker({ function createChannelReadTracker({
@@ -2150,7 +2150,7 @@ function renderBody(screen, navigate, routeKey, channelData, handlers) {
if (!unreadLineInserted && item.type === 'post' && Number(item?.post?.localNumber || 0) > readCount) { if (!unreadLineInserted && item.type === 'post' && Number(item?.post?.localNumber || 0) > readCount) {
const unreadLine = document.createElement('div'); const unreadLine = document.createElement('div');
unreadLine.className = 'card channel-unread-line'; unreadLine.className = 'card channel-unread-line';
unreadLine.textContent = `Не прочитано: ${unreadCount}`; unreadLine.textContent = 'Не прочитанные сообщения';
feed.append(unreadLine); feed.append(unreadLine);
unreadLineInserted = true; unreadLineInserted = true;
} }
+8 -2
View File
@@ -1,5 +1,5 @@
import { renderHeader } from '../components/header.js'; import { renderHeader } from '../components/header.js';
import { authService, clearAuthMessages, state } from '../state.js'; import { authService, clearAuthMessages, resetRegistrationFlow, state } from '../state.js';
import { toUserMessage } from '../services/ui-error-texts.js'; import { toUserMessage } from '../services/ui-error-texts.js';
import { import {
checkLoginExistsOnSolana, checkLoginExistsOnSolana,
@@ -426,7 +426,13 @@ export function render({ navigate }) {
screen.append( screen.append(
renderHeader({ renderHeader({
title: 'Зарегистрироваться', title: 'Зарегистрироваться',
leftAction: { label: '←', onClick: () => navigate('start-view') }, leftAction: {
label: '←',
onClick: () => {
resetRegistrationFlow();
navigate('start-view');
},
},
}), }),
form, form,
actions, actions,
+12 -2
View File
@@ -3,6 +3,7 @@ import {
authService, authService,
authorizeSession, authorizeSession,
refreshSessions, refreshSessions,
resetRegistrationFlow,
setAuthError, setAuthError,
setAuthInfo, setAuthInfo,
state, state,
@@ -102,7 +103,10 @@ export function render({ navigate }) {
cancelButton.className = 'ghost-btn'; cancelButton.className = 'ghost-btn';
cancelButton.type = 'button'; cancelButton.type = 'button';
cancelButton.textContent = 'Отмена'; cancelButton.textContent = 'Отмена';
cancelButton.addEventListener('click', () => navigate('start-view')); cancelButton.addEventListener('click', () => {
resetRegistrationFlow();
navigate('start-view');
});
const okButton = document.createElement('button'); const okButton = document.createElement('button');
okButton.className = 'primary-btn'; okButton.className = 'primary-btn';
@@ -190,7 +194,13 @@ export function render({ navigate }) {
screen.append( screen.append(
renderHeader({ renderHeader({
title: 'Сохранение ключей', title: 'Сохранение ключей',
leftAction: { label: '←', onClick: () => navigate('start-view') }, leftAction: {
label: '←',
onClick: () => {
resetRegistrationFlow();
navigate('start-view');
},
},
}), }),
card, card,
actions, actions,
@@ -3,6 +3,7 @@ import {
authService, authService,
authorizeSession, authorizeSession,
refreshSessions, refreshSessions,
resetRegistrationFlow,
setAuthError, setAuthError,
setAuthInfo, setAuthInfo,
state, state,
@@ -553,6 +554,7 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
replacement.addEventListener('click', () => { replacement.addEventListener('click', () => {
stageClosed = true; stageClosed = true;
stopTimers(); stopTimers();
resetRegistrationFlow();
navigate('start-view'); navigate('start-view');
}); });
headerBackButton.replaceWith(replacement); headerBackButton.replaceWith(replacement);
@@ -657,6 +659,7 @@ function renderSolanaDoneStage({ navigate, status, keyBundle, registrationTxId =
replacement.addEventListener('click', () => { replacement.addEventListener('click', () => {
loginCompleted = true; loginCompleted = true;
stopAutoLogin(); stopAutoLogin();
resetRegistrationFlow();
navigate('start-view'); navigate('start-view');
}); });
headerBackButton.replaceWith(replacement); headerBackButton.replaceWith(replacement);
+8
View File
@@ -925,6 +925,14 @@ export async function refreshSessions() {
return state.sessions; return state.sessions;
} }
export function resetRegistrationFlow() {
const next = createInitialState();
state.registrationDraft = next.registrationDraft;
state.registrationHelp = next.registrationHelp;
state.registrationPayment = next.registrationPayment;
state.keyStorage = next.keyStorage;
}
function resetStateForSignedOut() { function resetStateForSignedOut() {
const next = createInitialState({ withStoredSession: false }); const next = createInitialState({ withStoredSession: false });
state.chats = next.chats; state.chats = next.chats;