Fix unread channel counts and badges

This commit is contained in:
AidarKC
2026-08-21 13:45:49 +04:00
parent 47a4844ce8
commit 745a0e39d7
5 changed files with 18 additions and 7 deletions
+7 -2
View File
@@ -237,6 +237,7 @@ function buildThreadRoute(messageRef, selector) {
function buildChannelSettingsKey(ownerBlockchainName, channelName) {
const ownerBch = String(ownerBlockchainName || '').trim();
const name = String(channelName || '').trim();
if (!ownerBch || !name) return '';
return `${ownerBch}/${name}`;
}
@@ -1370,7 +1371,7 @@ async function loadFromApi(route, channelId) {
throw new Error('Канал не найден.');
}
unreadCount = Number(channel?.unreadCount || 0);
messagesCount = Number(channel?.messagesCount || mergedMessages.length || 0);
messagesCount = Number(channel?.messagesCount || 0);
selector = {
ownerBlockchainName: String(channel.channel.ownerBlockchainName),
channelRootBlockNumber: Number(channel.channel.channelRoot.blockNumber),
@@ -1447,6 +1448,7 @@ async function loadFromApi(route, channelId) {
return {
channel: {
name: payload.channel?.channelName || 'неизвестный канал',
ownerBlockchainName: String(payload.channel?.ownerBlockchainName || '').trim(),
displayTitle: String(payload.channel?.displayName || payload.channel?.channelName || 'неизвестный канал').trim(),
displayName: `${ownerLogin || 'неизвестно'}/${payload.channel?.channelName || 'неизвестный канал'}`,
description: String(payload.channel?.channelDescription || '').trim(),
@@ -2318,7 +2320,10 @@ export function render({ navigate, route, chrome }) {
const apiData = await loadFromApi(route, channelId);
activeSelector = apiData?.selector || null;
const lastSeenCount = Number(apiData?.messagesCount || (Array.isArray(apiData?.posts) ? apiData.posts.length : 0) || 0);
const settingKey = buildChannelSettingsKey(apiData?.channel?.ownerBlockchainName, apiData?.channel?.name);
const settingKey = buildChannelSettingsKey(
apiData?.channel?.ownerBlockchainName || apiData?.selector?.ownerBlockchainName,
apiData?.channel?.name || apiData?.channel?.channelName,
);
if (settingKey && state.session.login && state.session.storagePwdInMemory) {
void authService.upsertUserSetting({
login: state.session.login,