SHA256
Вернуть channels-list к версии ui-artem
This commit is contained in:
@@ -1217,6 +1217,7 @@ function renderListContent({ screen, container, listState, navigate, refreshFeed
|
|||||||
|
|
||||||
const main = renderChannelMain(channel);
|
const main = renderChannelMain(channel);
|
||||||
|
|
||||||
|
const isGuest = !state.session.isAuthorized;
|
||||||
const controls = document.createElement('div');
|
const controls = document.createElement('div');
|
||||||
controls.className = 'channel-row-controls';
|
controls.className = 'channel-row-controls';
|
||||||
|
|
||||||
@@ -1227,10 +1228,7 @@ function renderListContent({ screen, container, listState, navigate, refreshFeed
|
|||||||
const count = document.createElement('span');
|
const count = document.createElement('span');
|
||||||
count.className = 'unread channel-row-count';
|
count.className = 'unread channel-row-count';
|
||||||
const unreadCount = Number(channel.unreadCount || 0);
|
const unreadCount = Number(channel.unreadCount || 0);
|
||||||
if (unreadCount > 0) {
|
count.textContent = unreadCount > 0 ? String(unreadCount) : '';
|
||||||
count.textContent = unreadCount > 99 ? '99+' : String(unreadCount);
|
|
||||||
controls.append(count);
|
|
||||||
}
|
|
||||||
count.classList.toggle('is-empty', unreadCount <= 0);
|
count.classList.toggle('is-empty', unreadCount <= 0);
|
||||||
|
|
||||||
if (!isGuest) {
|
if (!isGuest) {
|
||||||
@@ -1261,7 +1259,7 @@ function renderListContent({ screen, container, listState, navigate, refreshFeed
|
|||||||
});
|
});
|
||||||
controls.append(menuButton);
|
controls.append(menuButton);
|
||||||
}
|
}
|
||||||
controls.append(time);
|
controls.append(time, count);
|
||||||
|
|
||||||
row.append(avatar, main, controls);
|
row.append(avatar, main, controls);
|
||||||
row.addEventListener('click', () => {
|
row.addEventListener('click', () => {
|
||||||
@@ -1278,6 +1276,14 @@ function renderListContent({ screen, container, listState, navigate, refreshFeed
|
|||||||
container.append(list);
|
container.append(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateBottomCta({ button }) {
|
||||||
|
if (!button) return;
|
||||||
|
button.hidden = true;
|
||||||
|
button.textContent = '';
|
||||||
|
button.className = 'channels-bottom-action';
|
||||||
|
button.onclick = null;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadFeedAndRender({ screen, listState, contentEl, navigate }) {
|
async function loadFeedAndRender({ screen, listState, contentEl, navigate }) {
|
||||||
closeChannelMenu(listState);
|
closeChannelMenu(listState);
|
||||||
renderSkeletonList(contentEl, 5);
|
renderSkeletonList(contentEl, 5);
|
||||||
@@ -1391,6 +1397,9 @@ export function render({ navigate, route, chrome }) {
|
|||||||
topBarRight.append(topMenuBtn);
|
topBarRight.append(topMenuBtn);
|
||||||
topBarEl.append(topBarLeft, topTitle, topBarRight);
|
topBarEl.append(topBarLeft, topTitle, topBarRight);
|
||||||
|
|
||||||
|
const bottomCta = document.createElement('button');
|
||||||
|
bottomCta.type = 'button';
|
||||||
|
|
||||||
const reloadFeed = async () => loadFeedAndRender({ screen, listState, contentEl, navigate });
|
const reloadFeed = async () => loadFeedAndRender({ screen, listState, contentEl, navigate });
|
||||||
|
|
||||||
const rerenderList = () => {
|
const rerenderList = () => {
|
||||||
@@ -1409,15 +1418,19 @@ export function render({ navigate, route, chrome }) {
|
|||||||
topTitle.textContent = channelsViewTitle(listState.viewMode);
|
topTitle.textContent = channelsViewTitle(listState.viewMode);
|
||||||
topMenuBtn.style.display = '';
|
topMenuBtn.style.display = '';
|
||||||
if (topTitle.parentElement !== topBarEl) topBarEl.insertBefore(topTitle, topBarRight);
|
if (topTitle.parentElement !== topBarEl) topBarEl.insertBefore(topTitle, topBarRight);
|
||||||
|
|
||||||
|
updateBottomCta({ button: bottomCta });
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome?.setTopbar(topBarEl);
|
chrome?.setTopbar(topBarEl);
|
||||||
screen.append(contentEl);
|
screen.append(contentEl, bottomCta);
|
||||||
|
|
||||||
if (createSuccessFlash) {
|
if (createSuccessFlash) {
|
||||||
showToast(createSuccessFlash);
|
showToast(createSuccessFlash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateBottomCta({ button: bottomCta });
|
||||||
|
|
||||||
// Применяем корректное состояние хедера сразу на первом рендере,
|
// Применяем корректное состояние хедера сразу на первом рендере,
|
||||||
// чтобы не показывать лишние кнопки до первой перерисовки.
|
// чтобы не показывать лишние кнопки до первой перерисовки.
|
||||||
rerenderList();
|
rerenderList();
|
||||||
|
|||||||
Reference in New Issue
Block a user