SHA256
Вложения файлов со своего сервера доступа пользователя
This commit is contained in:
@@ -21,7 +21,7 @@ function setStatusBadge(node, status, label) {
|
||||
|
||||
function renderTile(item, index) {
|
||||
const tile = document.createElement('article');
|
||||
tile.className = `ar-attachment-history-tile ar-attachment-history-tile--page${item?.preview?.ar ? ' ar-attachment-history-tile--with-preview' : ''}`;
|
||||
tile.className = 'ar-attachment-history-tile ar-attachment-history-tile--page';
|
||||
|
||||
const name = document.createElement('strong');
|
||||
name.className = 'ar-attachment-history-name';
|
||||
@@ -39,12 +39,6 @@ function renderTile(item, index) {
|
||||
const time = document.createElement('span');
|
||||
time.textContent = formatArweaveHistoryTime(item.uploadedAtMs);
|
||||
meta.append(status, size, time);
|
||||
if (item?.preview?.ar) {
|
||||
const previewFlag = document.createElement('span');
|
||||
previewFlag.className = 'ar-attachment-placement-flag';
|
||||
previewFlag.textContent = 'С превью';
|
||||
meta.append(previewFlag);
|
||||
}
|
||||
if (item.pendingPlacement) {
|
||||
const flag = document.createElement('span');
|
||||
flag.className = 'ar-attachment-placement-flag';
|
||||
|
||||
@@ -2,6 +2,7 @@ import { iconHtml } from '../components/ui-icon.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import { confirmDialog } from '../components/confirm-dialog.js';
|
||||
import { renderAvatar } from '../components/avatar-image.js';
|
||||
import { markArweaveAttachmentPlaced, openArweaveAttachmentManager } from '../components/arweave-attachment-manager.js';
|
||||
import { authService, setChannelsFeed, state } from '../state.js';
|
||||
import { navigateBack, getPreviousTrackedPath } from '../router.js';
|
||||
import {
|
||||
@@ -70,6 +71,112 @@ function ownerDisplayName(snapshot, ownerLogin) {
|
||||
return [firstName, lastName].filter(Boolean).join(' ').trim() || String(ownerLogin || '').trim() || 'Владелец канала';
|
||||
}
|
||||
|
||||
function formatChannelCreatedAt(value) {
|
||||
const time = Number(value || 0);
|
||||
if (!Number.isFinite(time) || time <= 0) return 'Неизвестно';
|
||||
try {
|
||||
return new Intl.DateTimeFormat('ru-RU', { day: '2-digit', month: 'long', year: 'numeric' }).format(new Date(time));
|
||||
} catch {
|
||||
return new Date(time).toLocaleDateString('ru-RU');
|
||||
}
|
||||
}
|
||||
|
||||
function openChannelProfileEditor({ channel, selector, onSaved }) {
|
||||
const root = document.getElementById('modal-root');
|
||||
if (!root) return;
|
||||
let selectedAvatar = String(channel?.avaAr || '').trim() ? {
|
||||
name: 'Аватар',
|
||||
ar: String(channel.avaAr || '').trim(),
|
||||
sha256: String(channel?.avaSha256 || '').trim(),
|
||||
size: Number(channel?.avaSize || 0),
|
||||
purpose: 'avatar',
|
||||
} : null;
|
||||
|
||||
const cleanTitle = String(channel?.displayName || channel?.displayTitle || channel?.channelName || '').trim();
|
||||
const cleanDescription = String(channel?.channelDescription || channel?.description || '').trim();
|
||||
|
||||
root.innerHTML = `
|
||||
<div class="modal" id="channel-profile-edit-modal">
|
||||
<div class="modal-card stack channel-profile-card">
|
||||
<h3 class="modal-title">Изменить профиль канала</h3>
|
||||
<div id="channel-profile-edit-avatar-preview"></div>
|
||||
<button class="secondary-btn" id="channel-profile-edit-avatar" type="button">Изменить аватар</button>
|
||||
<label class="meta-muted" for="channel-profile-edit-title">Публичное название</label>
|
||||
<input class="input" id="channel-profile-edit-title" type="text" maxlength="50" value="${escapeHtml(cleanTitle)}" />
|
||||
<label class="meta-muted" for="channel-profile-edit-description">Описание канала</label>
|
||||
<textarea class="input" id="channel-profile-edit-description" rows="4" maxlength="250">${escapeHtml(cleanDescription)}</textarea>
|
||||
<p class="meta-muted inline-error" id="channel-profile-edit-error"></p>
|
||||
<div class="form-actions-grid">
|
||||
<button class="secondary-btn" id="channel-profile-edit-cancel" type="button">Отмена</button>
|
||||
<button class="primary-btn" id="channel-profile-edit-save" type="button">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const renderPreview = () => {
|
||||
const slot = root.querySelector('#channel-profile-edit-avatar-preview');
|
||||
if (!slot) return;
|
||||
const title = String(root.querySelector('#channel-profile-edit-title')?.value || cleanTitle).trim();
|
||||
slot.innerHTML = '';
|
||||
slot.append(renderAvatar({
|
||||
initials: (title || 'К').slice(0, 1).toUpperCase(),
|
||||
avatar: selectedAvatar?.ar ? { ar: selectedAvatar.ar } : null,
|
||||
size: 'xl',
|
||||
className: 'channel-about-avatar channel-profile-avatar',
|
||||
title: title || 'Канал',
|
||||
alt: 'Аватар канала',
|
||||
}));
|
||||
};
|
||||
renderPreview();
|
||||
|
||||
root.querySelector('#channel-profile-edit-cancel')?.addEventListener('click', () => { root.innerHTML = ''; });
|
||||
root.querySelector('#channel-profile-edit-title')?.addEventListener('input', renderPreview);
|
||||
root.querySelector('#channel-profile-edit-avatar')?.addEventListener('click', async () => {
|
||||
const errorEl = root.querySelector('#channel-profile-edit-error');
|
||||
try {
|
||||
const item = await openArweaveAttachmentManager({
|
||||
login: state.session.login,
|
||||
storagePwd: state.session.storagePwdInMemory,
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
mode: 'avatar',
|
||||
historyPurpose: 'avatar',
|
||||
});
|
||||
if (!item) return;
|
||||
selectedAvatar = item;
|
||||
renderPreview();
|
||||
} catch (error) {
|
||||
if (errorEl) errorEl.textContent = toUserMessage(error, 'Не удалось выбрать аватар.');
|
||||
}
|
||||
});
|
||||
|
||||
root.querySelector('#channel-profile-edit-save')?.addEventListener('click', async () => {
|
||||
const save = root.querySelector('#channel-profile-edit-save');
|
||||
const errorEl = root.querySelector('#channel-profile-edit-error');
|
||||
const title = String(root.querySelector('#channel-profile-edit-title')?.value || '').trim();
|
||||
const description = String(root.querySelector('#channel-profile-edit-description')?.value || '').trim();
|
||||
if (Array.from(title).length > 50 || Array.from(description).length > 250) {
|
||||
if (errorEl) errorEl.textContent = 'Название — до 50 символов, описание — до 250.';
|
||||
return;
|
||||
}
|
||||
save.disabled = true;
|
||||
if (errorEl) errorEl.textContent = '';
|
||||
try {
|
||||
const login = String(state.session.login || '').trim();
|
||||
const storagePwd = String(state.session.storagePwdInMemory || '').trim();
|
||||
if (!login || !storagePwd) throw new Error('Для изменения профиля нужно войти заново.');
|
||||
await authService.addBlockChannelMeta({ login, storagePwd, channel: selector, title, description, avatar: selectedAvatar });
|
||||
if (selectedAvatar?.ar) markArweaveAttachmentPlaced(login, selectedAvatar);
|
||||
root.innerHTML = '';
|
||||
showToast('Профиль канала обновлён');
|
||||
onSaved?.();
|
||||
} catch (error) {
|
||||
save.disabled = false;
|
||||
if (errorEl) errorEl.textContent = toUserMessage(error, 'Не удалось изменить профиль канала.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isSelectorMatch(row, selector) {
|
||||
return Boolean(
|
||||
row?.channel
|
||||
@@ -109,13 +216,26 @@ async function resolveChannelSelector(route) {
|
||||
String(item?.channel?.channelName || '').trim().toLowerCase() === channelName.toLowerCase()
|
||||
&& String(item?.channel?.ownerLogin || '').trim().toLowerCase() === ownerLoginNormalized
|
||||
));
|
||||
if (!row?.channel?.channelRoot) throw new Error('Канал не найден.');
|
||||
if (row?.channel?.channelRoot) {
|
||||
const rootBlockchainName = String(row.channel.ownerBlockchainName || ownerRef).trim();
|
||||
return {
|
||||
ownerBlockchainName: rootBlockchainName,
|
||||
channelRootBlockNumber: Number(row.channel.channelRoot.blockNumber),
|
||||
channelRootBlockHash: normalizeHash(row.channel.channelRoot.blockHash),
|
||||
channelName,
|
||||
};
|
||||
}
|
||||
|
||||
const rootBlockchainName = String(row.channel.ownerBlockchainName || ownerRef).trim();
|
||||
const profileChannels = await authService.listUserProfileChannels(ownerLogin, 'owned', 500, 0, true);
|
||||
const deletedRow = (Array.isArray(profileChannels?.channels) ? profileChannels.channels : []).find((item) => (
|
||||
String(item?.slug || '').trim().toLowerCase() === channelName.toLowerCase()
|
||||
&& String(item?.ownerLogin || '').trim().toLowerCase() === ownerLoginNormalized
|
||||
));
|
||||
if (!deletedRow) throw new Error('Канал не найден.');
|
||||
return {
|
||||
ownerBlockchainName: rootBlockchainName,
|
||||
channelRootBlockNumber: Number(row.channel.channelRoot.blockNumber),
|
||||
channelRootBlockHash: normalizeHash(row.channel.channelRoot.blockHash),
|
||||
ownerBlockchainName: String(deletedRow.ownerBlockchainName || ownerRef).trim(),
|
||||
channelRootBlockNumber: Number(deletedRow.rootBlockNumber),
|
||||
channelRootBlockHash: normalizeHash(deletedRow.rootBlockHashHex),
|
||||
channelName,
|
||||
};
|
||||
}
|
||||
@@ -479,6 +599,7 @@ export function render({ navigate, route, chrome }) {
|
||||
|
||||
<div class="channel-about-tiles">
|
||||
${cameFromChannel ? '' : `<button class="channel-about-tile" id="channel-about-open" type="button">${iconHtml('open')}<span>Открыть</span></button>`}
|
||||
${isOwnChannel ? `<button class="channel-about-tile" id="channel-about-edit" type="button">${iconHtml('edit')}<span>Изменить профиль</span></button>` : ''}
|
||||
${subscriptionTile}
|
||||
${isOwnChannel ? '' : `<button class="channel-about-tile" id="channel-about-support" type="button">${iconHtml('gift')}<span>Поддержать автора</span></button>`}
|
||||
</div>
|
||||
@@ -488,6 +609,9 @@ export function render({ navigate, route, chrome }) {
|
||||
<span class="channel-about-row-label">Описание</span>
|
||||
<p class="channel-about-description">${escapeHtml(description || 'Описание не задано.')}</p>
|
||||
</div>
|
||||
<div class="channel-about-row channel-about-row--static">
|
||||
<span class="channel-about-row-main"><span class="channel-about-row-label">Создан</span><strong>${escapeHtml(formatChannelCreatedAt(channel?.createdAtMs))}</strong></span>
|
||||
</div>
|
||||
<button class="channel-about-row" id="channel-about-owner" type="button">
|
||||
<span class="channel-about-owner-avatar" id="channel-about-owner-avatar"></span>
|
||||
<span class="channel-about-row-main">
|
||||
@@ -497,7 +621,7 @@ export function render({ navigate, route, chrome }) {
|
||||
<span class="channel-about-row-chevron">${iconHtml('chevron')}</span>
|
||||
</button>
|
||||
${isOwnChannel && !isDeleted ? `<button class="channel-about-row" id="channel-about-delete" type="button">
|
||||
<span class="channel-about-row-main"><span class="channel-about-row-label">Удалить канал</span><span class="meta-muted">Канал можно будет восстановить новой публикацией</span></span>
|
||||
<span class="channel-about-row-main"><span class="channel-about-row-label">Удалить канал</span><span class="meta-muted">Канал останется в блокчейне, но будет помечен как удалённый. Новая публикация восстановит его.</span></span>
|
||||
<span class="channel-about-row-chevron" aria-hidden="true">${iconHtml('trash')}</span>
|
||||
</button>` : ''}
|
||||
<button class="channel-about-row" id="channel-about-copy-row" type="button">
|
||||
@@ -526,6 +650,10 @@ export function render({ navigate, route, chrome }) {
|
||||
alt: '',
|
||||
}));
|
||||
|
||||
content.querySelector('#channel-about-edit')?.addEventListener('click', () => {
|
||||
requireSigningSession();
|
||||
openChannelProfileEditor({ channel, selector, onSaved: () => void refresh() });
|
||||
});
|
||||
content.querySelector('#channel-about-owner')?.addEventListener('click', () => {
|
||||
const profileRoute = makeProfileRoute(ownerLogin);
|
||||
if (profileRoute) navigate(profileRoute);
|
||||
|
||||
@@ -767,6 +767,9 @@ function renderNodeCard(node, heading, handlers, localNumber) {
|
||||
card.append(createAttachmentCarouselElement(parsedText.attachments, {
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
messageTimestampMs: node?.createdAtMs,
|
||||
authorLogin: author,
|
||||
solanaEndpoint: state.entrySettings.solanaServer,
|
||||
fallbackServerLogin: state.entrySettings.shineServerLogin,
|
||||
}));
|
||||
}
|
||||
if (isRating) {
|
||||
@@ -1009,6 +1012,15 @@ function renderThreadContext(node, { onOpenPost }) {
|
||||
toPost.addEventListener('click', onOpenPost);
|
||||
meta.append(time, expand, toPost);
|
||||
box.append(text, meta);
|
||||
if (parsed.attachments.length) {
|
||||
box.append(createAttachmentCarouselElement(parsed.attachments, {
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
messageTimestampMs: node?.createdAtMs,
|
||||
authorLogin: node?.authorLogin,
|
||||
solanaEndpoint: state.entrySettings.solanaServer,
|
||||
fallbackServerLogin: state.entrySettings.shineServerLogin,
|
||||
}));
|
||||
}
|
||||
// обрезан ли текст — видно только после вставки в документ
|
||||
requestAnimationFrame(() => { expand.hidden = text.scrollHeight <= text.clientHeight + 1; });
|
||||
return box;
|
||||
@@ -1066,7 +1078,13 @@ function renderComment({ node, parent, focus, channelOwner, handlers }) {
|
||||
}
|
||||
|
||||
if (parsed.attachments.length) {
|
||||
item.append(createAttachmentCarouselElement(parsed.attachments, { gateway: state.entrySettings.arweaveServer, messageTimestampMs: node?.createdAtMs }));
|
||||
item.append(createAttachmentCarouselElement(parsed.attachments, {
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
messageTimestampMs: node?.createdAtMs,
|
||||
authorLogin: node?.authorLogin,
|
||||
solanaEndpoint: state.entrySettings.solanaServer,
|
||||
fallbackServerLogin: state.entrySettings.shineServerLogin,
|
||||
}));
|
||||
}
|
||||
const text = document.createElement('p');
|
||||
text.className = 'thread-comment__text';
|
||||
|
||||
@@ -1417,6 +1417,38 @@ async function loadFromApi(route, channelId) {
|
||||
} catch {
|
||||
// ignore owner feed lookup failures
|
||||
}
|
||||
if (!channel) {
|
||||
try {
|
||||
const profileChannels = await authService.listUserProfileChannels(ownerLoginForLookup, 'owned', 500, 0, true);
|
||||
const deletedRow = (Array.isArray(profileChannels?.channels) ? profileChannels.channels : []).find((item) => (
|
||||
String(item?.slug || '').trim().toLowerCase() === selector.channelName.toLowerCase()
|
||||
&& String(item?.ownerLogin || '').trim().toLowerCase() === ownerLoginForLookup.toLowerCase()
|
||||
));
|
||||
if (deletedRow) {
|
||||
channel = {
|
||||
channel: {
|
||||
ownerLogin: deletedRow.ownerLogin,
|
||||
ownerBlockchainName: deletedRow.ownerBlockchainName,
|
||||
channelName: deletedRow.slug,
|
||||
displayName: deletedRow.displayName,
|
||||
avaAr: deletedRow.avatarAr,
|
||||
deleted: !!deletedRow.deleted,
|
||||
deletedAtMs: Number(deletedRow.deletedAtMs || 0),
|
||||
channelRoot: {
|
||||
blockNumber: Number(deletedRow.rootBlockNumber),
|
||||
blockHash: normalizeRouteHash(deletedRow.rootBlockHashHex),
|
||||
},
|
||||
},
|
||||
unreadCount: 0,
|
||||
messagesCount: 0,
|
||||
readCount: 0,
|
||||
readStateInitialized: true,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// ignore deleted-channel lookup failures
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!channel?.channel?.ownerBlockchainName || channel?.channel?.channelRoot?.blockNumber == null) {
|
||||
@@ -1956,6 +1988,9 @@ function renderPostCard(post, {
|
||||
card.append(createAttachmentCarouselElement(parsedBody.attachments, {
|
||||
gateway: state.entrySettings.arweaveServer,
|
||||
messageTimestampMs: post.timestampMs,
|
||||
authorLogin: post.authorLogin,
|
||||
solanaEndpoint: state.entrySettings.solanaServer,
|
||||
fallbackServerLogin: state.entrySettings.shineServerLogin,
|
||||
}));
|
||||
}
|
||||
if (post.isRating) {
|
||||
@@ -2451,7 +2486,7 @@ export function render({ navigate, route, chrome }) {
|
||||
className: 'channel-view-topbar topbar--identity',
|
||||
actions: [
|
||||
{
|
||||
label: '⋮',
|
||||
icon: 'moreVertical',
|
||||
title: 'Действия канала',
|
||||
ariaLabel: 'Открыть меню канала',
|
||||
className: 'channel-header-more-btn',
|
||||
@@ -2468,7 +2503,7 @@ export function render({ navigate, route, chrome }) {
|
||||
const aboutRoute = makeShineChannelAboutRoute(routeArgs);
|
||||
const donateRoute = makeShineChannelDonateRoute(routeArgs);
|
||||
const items = [];
|
||||
items.push({ label: 'О канале', iconHtml: iconHtml('info'), action: () => { if (aboutRoute) navigate(aboutRoute); } });
|
||||
items.push({ label: apiData?.isOwnChannel ? 'Редактировать' : 'О канале', iconHtml: iconHtml(apiData?.isOwnChannel ? 'edit' : 'info'), action: () => { if (aboutRoute) navigate(aboutRoute); } });
|
||||
if (apiData?.isOwnChannel && !apiData?.isDiary) {
|
||||
items.push({ label: 'Новая запись', iconHtml: iconHtml('compose'), action: () => activeAddMessage?.() });
|
||||
}
|
||||
@@ -2497,7 +2532,7 @@ export function render({ navigate, route, chrome }) {
|
||||
});
|
||||
}
|
||||
}
|
||||
const aboutIndex = items.findIndex((item) => item.label === 'О канале');
|
||||
const aboutIndex = items.findIndex((item) => item.label === 'О канале' || item.label === 'Редактировать');
|
||||
if (aboutIndex > 0) items.unshift(...items.splice(aboutIndex, 2));
|
||||
return items;
|
||||
},
|
||||
@@ -2946,7 +2981,15 @@ export function render({ navigate, route, chrome }) {
|
||||
restorePosition,
|
||||
showStatus,
|
||||
isActive: () => !disposed,
|
||||
onAddMessage: activeAddMessage = () => {
|
||||
onAddMessage: activeAddMessage = async () => {
|
||||
if (apiData?.channel?.deleted) {
|
||||
const confirmed = await confirmDialog({
|
||||
title: 'Восстановить канал?',
|
||||
text: 'Новое сообщение восстановит канал: он перестанет считаться удалённым и снова появится в обычном списке ваших каналов.',
|
||||
confirmLabel: 'Восстановить и написать',
|
||||
});
|
||||
if (!confirmed || disposed) return;
|
||||
}
|
||||
openAddMessageModal({
|
||||
channelName: apiData?.channel?.name || '',
|
||||
channelTitle: apiData?.channel?.displayTitle || '',
|
||||
|
||||
@@ -32,6 +32,7 @@ const DIARY_DISPLAY_NAME = 'Дневник';
|
||||
const CHANNELS_VIEW_ALL = 'all';
|
||||
const CHANNELS_VIEW_OWNED = 'owned';
|
||||
const CHANNELS_VIEW_FOLLOWING = 'following';
|
||||
const CHANNELS_VIEW_DELETED = 'deleted';
|
||||
const listQueries = new Map();
|
||||
|
||||
function channelMenuIcon(name) {
|
||||
@@ -278,18 +279,21 @@ function normalizeChannelsViewMode(route = null) {
|
||||
const scope = String(route?.params?.scope || '').trim().toLowerCase();
|
||||
if (mode === 'my' || scope === 'owned') return CHANNELS_VIEW_OWNED;
|
||||
if (mode === 'following' || scope === 'following') return CHANNELS_VIEW_FOLLOWING;
|
||||
if (mode === 'deleted' || scope === 'deleted') return CHANNELS_VIEW_DELETED;
|
||||
return CHANNELS_VIEW_ALL;
|
||||
}
|
||||
|
||||
function buildChannelsViewRoute(mode) {
|
||||
if (mode === CHANNELS_VIEW_OWNED) return 'channels/my';
|
||||
if (mode === CHANNELS_VIEW_FOLLOWING) return 'channels/following';
|
||||
if (mode === CHANNELS_VIEW_DELETED) return 'channels/deleted';
|
||||
return 'channels';
|
||||
}
|
||||
|
||||
function channelsViewTitle(mode) {
|
||||
if (mode === CHANNELS_VIEW_OWNED) return 'Мои каналы';
|
||||
if (mode === CHANNELS_VIEW_FOLLOWING) return 'Подписки';
|
||||
if (mode === CHANNELS_VIEW_DELETED) return 'Удалённые каналы';
|
||||
return 'Каналы';
|
||||
}
|
||||
|
||||
@@ -765,6 +769,46 @@ function mapApiChannelRow(summary, bucketKey, idx, index, notificationsState) {
|
||||
};
|
||||
}
|
||||
|
||||
function mapDeletedOwnedChannels(payload, notificationsState = {}) {
|
||||
const rows = Array.isArray(payload?.channels) ? payload.channels : [];
|
||||
return rows.filter((item) => item?.deleted === true).map((item, idx) => {
|
||||
const rowId = `own-deleted-${idx}`;
|
||||
const ownerLogin = String(item?.ownerLogin || state.session.login || '').trim();
|
||||
const channelName = String(item?.slug || '').trim();
|
||||
const displayTitle = String(item?.displayName || channelName || 'Канал').trim();
|
||||
return {
|
||||
id: rowId,
|
||||
sourceBucket: 'ownDeleted',
|
||||
route: makeShineChannelShortRoute({
|
||||
ownerBlockchainName: String(item?.ownerBlockchainName || '').trim(),
|
||||
channelName,
|
||||
}),
|
||||
ownerName: ownerLogin,
|
||||
ownerBlockchainName: String(item?.ownerBlockchainName || '').trim(),
|
||||
channelRootBlockNumber: Number(item?.rootBlockNumber),
|
||||
channelRootBlockHash: normalizeHash(item?.rootBlockHashHex),
|
||||
avatar: avatarLetterFromName(displayTitle),
|
||||
avaAr: String(item?.avatarAr || '').trim(),
|
||||
title: displayTitle,
|
||||
technicalLabel: `@${ownerLogin}/${channelName}`,
|
||||
channelName,
|
||||
displayTitle,
|
||||
channelDescription: '',
|
||||
channelTypeCode: 1,
|
||||
channelTypeVersion: 1,
|
||||
messagePreview: 'Канал помечен как удалённый',
|
||||
messagesCount: 0,
|
||||
unreadCount: 0,
|
||||
lastMessageAt: Number(item?.deletedAtMs || 0),
|
||||
isOwnChannel: true,
|
||||
isDeleted: true,
|
||||
isSubscribed: false,
|
||||
notificationsEnabled: notificationsState[rowId] === true,
|
||||
pending: false,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function pullCreateSuccessFlash() {
|
||||
try {
|
||||
const value = String(sessionStorage.getItem(CREATE_CHANNEL_FLASH_KEY) || '').trim();
|
||||
@@ -856,10 +900,10 @@ function renderEmptyState(listState, navigate) {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'channels-empty-state channels-empty-state--compact channels-empty-state--silent';
|
||||
const heading = document.createElement('strong');
|
||||
heading.textContent = listState.query ? 'Ничего не найдено' : listState.viewMode === CHANNELS_VIEW_FOLLOWING ? 'Пока нет подписок' : listState.viewMode === CHANNELS_VIEW_OWNED ? 'Здесь будут ваши каналы' : 'Откройте свой первый канал';
|
||||
heading.textContent = listState.query ? 'Ничего не найдено' : listState.viewMode === CHANNELS_VIEW_DELETED ? 'Удалённых каналов нет' : listState.viewMode === CHANNELS_VIEW_FOLLOWING ? 'Пока нет подписок' : listState.viewMode === CHANNELS_VIEW_OWNED ? 'Здесь будут ваши каналы' : 'Откройте свой первый канал';
|
||||
const text = document.createElement('p');
|
||||
text.className = 'meta-muted';
|
||||
text.textContent = state.session.isAuthorized ? 'Найдите канал по имени автора или создайте свой.' : 'Войдите, чтобы видеть свои каналы и подписки.';
|
||||
text.textContent = listState.viewMode === CHANNELS_VIEW_DELETED ? 'Здесь появятся только ваши каналы, помеченные как удалённые.' : state.session.isAuthorized ? 'Найдите канал по имени автора или создайте свой.' : 'Войдите, чтобы видеть свои каналы и подписки.';
|
||||
const action = document.createElement('button');
|
||||
action.type = 'button';
|
||||
action.className = 'primary-btn';
|
||||
@@ -1005,9 +1049,10 @@ function renderListContent({ screen, container, listState, navigate, refreshFeed
|
||||
|
||||
const allChannels = listState.channels || [];
|
||||
const filtered = allChannels.filter((channel) => {
|
||||
if (listState.viewMode === CHANNELS_VIEW_OWNED) return channel.isOwnChannel === true;
|
||||
if (listState.viewMode === CHANNELS_VIEW_OWNED) return channel.isOwnChannel === true && channel.isDeleted !== true;
|
||||
if (listState.viewMode === CHANNELS_VIEW_FOLLOWING) return channel.sourceBucket === 'followedChannels';
|
||||
return true;
|
||||
if (listState.viewMode === CHANNELS_VIEW_DELETED) return channel.isDeleted === true;
|
||||
return channel.isDeleted !== true;
|
||||
}).filter((channel) => {
|
||||
const query = String(listState.query || '').trim().toLowerCase();
|
||||
if (!query) return true;
|
||||
@@ -1091,6 +1136,20 @@ async function loadFeedAndRender({ screen, listState, contentEl, navigate, silen
|
||||
}
|
||||
|
||||
try {
|
||||
if (listState.viewMode === CHANNELS_VIEW_DELETED) {
|
||||
const payload = await authService.listUserProfileChannels(state.session.login, 'owned', 500, 0, true);
|
||||
if (listState.disposed || seq !== listState.loadSeq) return;
|
||||
listState.channels = mapDeletedOwnedChannels(payload, listState.notificationsState);
|
||||
renderListContent({
|
||||
screen,
|
||||
container: contentEl,
|
||||
listState,
|
||||
navigate,
|
||||
refreshFeed: async () => loadFeedAndRender({ screen, listState, contentEl, navigate }),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const feed = await authService.listSubscriptionsFeed(state.session.login, 200);
|
||||
if (listState.disposed || seq !== listState.loadSeq) return;
|
||||
|
||||
@@ -1160,15 +1219,25 @@ export function render({ navigate, route, chrome }) {
|
||||
contentEl.className = 'channels-list-content';
|
||||
|
||||
const topBarEl = createTopBar({
|
||||
title: 'Каналы',
|
||||
title: channelsViewTitle(listState.viewMode),
|
||||
className: 'topbar--root',
|
||||
actions: [
|
||||
{
|
||||
icon: 'plus',
|
||||
title: 'Создать канал',
|
||||
ariaLabel: 'Создать канал',
|
||||
className: 'channels-create-btn',
|
||||
onClick: () => navigate('add-channel-view'),
|
||||
icon: 'moreVertical',
|
||||
title: 'Меню каналов',
|
||||
ariaLabel: 'Открыть меню каналов',
|
||||
className: 'channels-menu-btn',
|
||||
menu: {
|
||||
minWidth: 240,
|
||||
items: () => [
|
||||
{ label: 'Создать канал', iconHtml: channelMenuIcon('add'), action: () => navigate('add-channel-view') },
|
||||
{ divider: true },
|
||||
{ label: 'Показать все каналы', iconHtml: channelMenuIcon('all'), selected: listState.viewMode === CHANNELS_VIEW_ALL, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_ALL)) },
|
||||
{ label: 'Показать подписки', iconHtml: channelMenuIcon('following'), selected: listState.viewMode === CHANNELS_VIEW_FOLLOWING, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_FOLLOWING)) },
|
||||
{ label: 'Показать мои', iconHtml: channelMenuIcon('mine'), selected: listState.viewMode === CHANNELS_VIEW_OWNED, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_OWNED)) },
|
||||
{ label: 'Показать мои удалённые каналы', iconHtml: iconHtml('trash'), selected: listState.viewMode === CHANNELS_VIEW_DELETED, action: () => navigate(buildChannelsViewRoute(CHANNELS_VIEW_DELETED)) },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user