Исправить открытие канала и ключ настройки

This commit is contained in:
AidarKC
2026-08-19 20:34:41 +04:00
parent 6a5c20a165
commit 5763eb828e
+7 -5
View File
@@ -234,8 +234,8 @@ function buildThreadRoute(messageRef, selector) {
}); });
} }
function buildChannelSettingsKey(selector, channelName) { function buildChannelSettingsKey(ownerBlockchainName, channelName) {
const ownerBch = String(selector?.ownerBlockchainName || '').trim(); const ownerBch = String(ownerBlockchainName || '').trim();
const name = String(channelName || '').trim(); const name = String(channelName || '').trim();
return `${ownerBch}/${name}`; return `${ownerBch}/${name}`;
} }
@@ -1364,6 +1364,8 @@ async function loadFromApi(route, channelId) {
if (!channel?.channel?.ownerBlockchainName || channel?.channel?.channelRoot?.blockNumber == null) { if (!channel?.channel?.ownerBlockchainName || channel?.channel?.channelRoot?.blockNumber == null) {
throw new Error('Канал не найден.'); throw new Error('Канал не найден.');
} }
unreadCount = Number(channel?.unreadCount || 0);
messagesCount = Number(channel?.messagesCount || mergedMessages.length || 0);
selector = { selector = {
ownerBlockchainName: String(channel.channel.ownerBlockchainName), ownerBlockchainName: String(channel.channel.ownerBlockchainName),
channelRootBlockNumber: Number(channel.channel.channelRoot.blockNumber), channelRootBlockNumber: Number(channel.channel.channelRoot.blockNumber),
@@ -1380,8 +1382,8 @@ async function loadFromApi(route, channelId) {
const messages = Array.isArray(payload.messages) ? payload.messages : []; const messages = Array.isArray(payload.messages) ? payload.messages : [];
let reverseChannelMissingWarning = ''; let reverseChannelMissingWarning = '';
let mergedMessages = [...messages]; let mergedMessages = [...messages];
const unreadCount = Number(channel?.unreadCount || 0); let unreadCount = 0;
const messagesCount = Number(channel?.messagesCount || mergedMessages.length || 0); let messagesCount = mergedMessages.length;
const currentLogin = currentSessionLogin; const currentLogin = currentSessionLogin;
const ownerLogin = String(payload.channel?.ownerLogin || '').trim(); const ownerLogin = String(payload.channel?.ownerLogin || '').trim();
@@ -2312,7 +2314,7 @@ export function render({ navigate, route, chrome }) {
const apiData = await loadFromApi(route, channelId); const apiData = await loadFromApi(route, channelId);
activeSelector = apiData?.selector || null; activeSelector = apiData?.selector || null;
const lastSeenCount = Number(apiData?.messagesCount || (Array.isArray(apiData?.posts) ? apiData.posts.length : 0) || 0); const lastSeenCount = Number(apiData?.messagesCount || (Array.isArray(apiData?.posts) ? apiData.posts.length : 0) || 0);
const settingKey = buildChannelSettingsKey(apiData?.selector, apiData?.channel?.name); const settingKey = buildChannelSettingsKey(apiData?.channel?.ownerBlockchainName, apiData?.channel?.name);
if (settingKey && state.session.login && state.session.storagePwdInMemory) { if (settingKey && state.session.login && state.session.storagePwdInMemory) {
void authService.upsertUserSetting({ void authService.upsertUserSetting({
login: state.session.login, login: state.session.login,