Добавить страницу донатов канала

This commit is contained in:
AidarKC
2026-09-17 22:43:49 +03:00
parent 7b81d140ec
commit 7aa05dc609
10 changed files with 1609 additions and 124 deletions
+38 -9
View File
@@ -31,6 +31,7 @@ import {
makeProfileRoute,
makeShineMessageRoute,
makeShineChannelAboutRoute,
makeShineChannelDonateRoute,
} from '../services/shine-routes.js';
import { parseDmTechBlocks } from '../services/dm-tech-blocks.js';
@@ -669,7 +670,7 @@ function openChannelMetaDetailsModal({
function openAboutChannelModal(channel, options = {}) {
openChannelMetaDetailsModal({
title: 'О канале',
title: 'Описание канала',
channel,
canEdit: options.canEdit === true,
onEdit: options.onEdit,
@@ -1595,9 +1596,13 @@ async function loadFromApi(route, channelId) {
try {
const ownerFeed = await authService.listSubscriptionsFeed(ownerLoginForLookup, 500);
const ownerRows = Array.isArray(ownerFeed?.ownedChannels) ? ownerFeed.ownedChannels : [];
const ownerLoginNormalized = ownerLoginForLookup.toLowerCase();
channel = ownerRows.find((item) => (
String(item?.channel?.ownerBlockchainName || '').trim().toLowerCase() === routeOwnerNormalized
&& String(item?.channel?.channelName || '').trim().toLowerCase() === selector.channelName.toLowerCase()
String(item?.channel?.channelName || '').trim().toLowerCase() === selector.channelName.toLowerCase()
&& (
String(item?.channel?.ownerBlockchainName || '').trim().toLowerCase() === routeOwnerNormalized
|| String(item?.channel?.ownerLogin || '').trim().toLowerCase() === ownerLoginNormalized
)
));
} catch {
// ignore owner feed lookup failures
@@ -2535,7 +2540,7 @@ export function render({ navigate, route, chrome }) {
actions: [
{ label: 'Оглавление', className: 'channel-header-entrypoint-btn', onClick: () => {} },
{
label: '',
label: '',
title: 'Действия канала',
ariaLabel: 'Открыть меню канала',
className: 'channel-header-more-btn',
@@ -2544,14 +2549,38 @@ export function render({ navigate, route, chrome }) {
items: () => {
const apiData = activeChannelData;
if (!apiData) return [];
const aboutRoute = makeShineChannelAboutRoute({
const routeArgs = {
ownerBlockchainName: apiData?.channel?.ownerBlockchainName || apiData?.selector?.ownerBlockchainName || '',
channelRootBlockNumber: apiData?.selector?.channelRootBlockNumber ?? apiData?.channel?.channelRoot?.blockNumber ?? '',
channelRootBlockHash: apiData?.selector?.channelRootBlockHash ?? apiData?.channel?.channelRoot?.blockHash ?? '',
});
const items = [
{ label: 'О канале', action: () => { if (aboutRoute) navigate(aboutRoute); } },
];
};
const aboutRoute = makeShineChannelAboutRoute(routeArgs);
const donateRoute = makeShineChannelDonateRoute(routeArgs);
const items = [];
if (apiData?.isOwnChannel && !apiData?.isDiary) {
items.push({
label: 'Добавить сообщение',
action: () => {
openAddMessageModal({
channelName: apiData?.channel?.name || '',
navigate,
isActive: () => !disposed,
onSubmit: async ({ text: bodyText, msgSubType }) => {
try {
await onAddPost(bodyText, msgSubType);
showStatus('');
} catch (error) {
throw new Error(toUserMessage(error, 'Не удалось добавить сообщение.'));
}
},
});
},
});
}
items.push({ label: 'Описание канала', action: () => { if (aboutRoute) navigate(aboutRoute); } });
if (!apiData?.isOwnChannel) {
items.push({ label: 'Поддержать автора', action: () => { if (donateRoute) navigate(donateRoute); } });
}
if (!apiData?.isOwnChannel && !isStoriesChannel(apiData?.channel)) {
if (apiData?.isSubscribed) {
items.push({