SHA256
UI: без мигания заглушек при переходах, заглушки в форме экранов, ширина окон поиска
Список каналов при повторном заходе показывается сразу из уже загруженных данных и обновляется в фоне; профиль – так же (последняя карточка). Заглушка появляется, только если загрузка дольше 250 мс, и повторяет экран: строки списка с круглым аватаром или записи с аватаром слева (createSkeletonRows). Окно «Поиск каналов» и окна экрана серверов доступа – без жёсткой ширины 96vw/94vw, поэтому на телефоне шторка снова во всю ширину.
This commit is contained in:
@@ -7,6 +7,10 @@ import { profileCardHtml, profileTileHtml } from '../components/profile-card.js'
|
||||
|
||||
export const pageMeta = { id: 'profile-view', title: 'Профиль' };
|
||||
|
||||
// Последняя загруженная карточка своего профиля: при повторном заходе показываем её сразу и тихо обновляем.
|
||||
const cardCache = new Map();
|
||||
const STATUS_DELAY_MS = 250;
|
||||
|
||||
export function render({ navigate, chrome }) {
|
||||
const login = String(state.session.login || profile.login || '').trim();
|
||||
const screen = document.createElement('section');
|
||||
@@ -20,14 +24,15 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
const status = document.createElement('div');
|
||||
status.className = 'status-line user-profile-status';
|
||||
status.textContent = 'Загрузка профиля...';
|
||||
let card = cardCache.get(login.toLowerCase()) || null;
|
||||
if (!card) {
|
||||
window.setTimeout(() => { if (!card && status.isConnected && !status.textContent) status.textContent = 'Загрузка профиля...'; }, STATUS_DELAY_MS);
|
||||
}
|
||||
|
||||
const body = document.createElement('div');
|
||||
body.className = 'user-profile-body';
|
||||
screen.append(status, body);
|
||||
|
||||
let card = null;
|
||||
|
||||
function renderProfile() {
|
||||
if (!card) return;
|
||||
body.innerHTML = profileCardHtml({
|
||||
@@ -83,11 +88,17 @@ export function render({ navigate, chrome }) {
|
||||
status.textContent = 'Локальный тестовый режим.';
|
||||
return;
|
||||
}
|
||||
card = await loadUserProfileCard(login);
|
||||
const fresh = await loadUserProfileCard(login);
|
||||
if (!screen.isConnected && card) return;
|
||||
card = fresh;
|
||||
cardCache.set(login.toLowerCase(), card);
|
||||
renderProfile();
|
||||
}
|
||||
|
||||
renderProfile();
|
||||
|
||||
refresh().catch((error) => {
|
||||
if (card) return;
|
||||
status.className = 'status-line user-profile-status is-unavailable';
|
||||
status.textContent = `Ошибка: ${error?.message || 'unknown'}`;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user