SHA256
Исправил баг UI: PWA и просмотр аватаров
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { profile } from '../mock-data.js';
|
||||
import { state } from '../state.js';
|
||||
import { renderUserAvatar } from '../components/avatar-image.js';
|
||||
import { attachProfileAvatarPreview } from '../components/profile-avatar-preview.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import { loadUserProfileCard } from '../services/user-connections.js';
|
||||
import { profileCardHtml, profileTileHtml } from '../components/profile-card.js';
|
||||
@@ -47,8 +47,12 @@ export function render({ navigate, chrome }) {
|
||||
body.className = 'user-profile-body';
|
||||
screen.append(status, body);
|
||||
|
||||
let avatarPreview = null;
|
||||
let disposed = false;
|
||||
function renderProfile() {
|
||||
if (!card) return;
|
||||
if (!card || disposed) return;
|
||||
avatarPreview?.cleanup();
|
||||
avatarPreview = null;
|
||||
body.innerHTML = profileCardHtml({
|
||||
card,
|
||||
login,
|
||||
@@ -62,16 +66,7 @@ export function render({ navigate, chrome }) {
|
||||
<button class="nav-row" type="button" data-self-profile-action="profiles"><span class="nav-row__label">${th('screens.profile_view.text_015')}</span><span class="nav-row__hint">${th('screens.profile_view.text_016')}</span></button>
|
||||
</div>`;
|
||||
|
||||
const avatarSlot = body.querySelector('.user-profile-avatar-slot');
|
||||
avatarSlot?.append(renderUserAvatar({
|
||||
login: card.login,
|
||||
firstName: card.firstName,
|
||||
lastName: card.lastName,
|
||||
avatar: card.avatar,
|
||||
size: 'xl',
|
||||
className: 'user-profile-hero-avatar',
|
||||
official: card.accountRole === 'primary',
|
||||
}));
|
||||
avatarPreview = attachProfileAvatarPreview(body.querySelector('.user-profile-avatar-slot'), card);
|
||||
|
||||
status.replaceChildren();
|
||||
}
|
||||
@@ -104,7 +99,7 @@ export function render({ navigate, chrome }) {
|
||||
return;
|
||||
}
|
||||
const fresh = await loadUserProfileCard(login);
|
||||
if (!screen.isConnected && card) return;
|
||||
if (disposed || (!screen.isConnected && card)) return;
|
||||
// Та же карточка – не перерисовываем, иначе аватар и счётчики мигают.
|
||||
if (card && JSON.stringify(card) === JSON.stringify(fresh)) return;
|
||||
card = fresh;
|
||||
@@ -127,5 +122,10 @@ export function render({ navigate, chrome }) {
|
||||
};
|
||||
refresh().catch(showLoadError);
|
||||
|
||||
screen.cleanup = () => {
|
||||
disposed = true;
|
||||
avatarPreview?.cleanup();
|
||||
avatarPreview = null;
|
||||
};
|
||||
return screen;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user