SHA256
Доработать UI и счётчики
This commit is contained in:
@@ -290,6 +290,8 @@ function createChannelReadTracker({
|
||||
unreadCount,
|
||||
messagesCount,
|
||||
initialSeenCount,
|
||||
onPersistError = null,
|
||||
onPersistSuccess = null,
|
||||
}) {
|
||||
const login = String(state.session.login || '').trim();
|
||||
const storagePwd = state.session.storagePwdInMemory;
|
||||
@@ -343,7 +345,9 @@ function createChannelReadTracker({
|
||||
storagePwd,
|
||||
});
|
||||
persistedSeenCount = next;
|
||||
} catch {
|
||||
if (typeof onPersistSuccess === 'function') onPersistSuccess(persistedSeenCount);
|
||||
} catch (error) {
|
||||
if (typeof onPersistError === 'function') onPersistError(error);
|
||||
queueFlush(800);
|
||||
} finally {
|
||||
inFlight = false;
|
||||
@@ -393,10 +397,8 @@ function createChannelReadTracker({
|
||||
}
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
if (canWrite) {
|
||||
desiredSeenCount = safeMessagesCount;
|
||||
void flush();
|
||||
}
|
||||
// Opening a channel must NOT mark the whole channel as read.
|
||||
// Only cards actually crossed by the viewport tracker advance desiredSeenCount.
|
||||
window.setTimeout(() => measure(), 120);
|
||||
|
||||
const cleanup = () => {
|
||||
@@ -2230,6 +2232,12 @@ function renderBody(screen, navigate, routeKey, channelData, handlers) {
|
||||
unreadCount,
|
||||
messagesCount,
|
||||
initialSeenCount: readCount,
|
||||
onPersistError: () => {
|
||||
showStatus('Не удалось сохранить, сколько сообщений прочитано. Сервер повторит попытку автоматически.');
|
||||
},
|
||||
onPersistSuccess: () => {
|
||||
showStatus('');
|
||||
},
|
||||
});
|
||||
|
||||
return () => {
|
||||
@@ -2785,6 +2793,24 @@ export function render({ navigate, route, chrome }) {
|
||||
});
|
||||
if (disposed) return;
|
||||
|
||||
const readSettingKey = buildChannelSettingsKey(
|
||||
apiData.channel?.ownerBlockchainName || apiData.selector?.ownerBlockchainName,
|
||||
apiData.channel?.name || apiData.channel?.channelName,
|
||||
);
|
||||
try {
|
||||
await authService.upsertUserSetting({
|
||||
login,
|
||||
settingType: 1,
|
||||
settingKey: readSettingKey,
|
||||
timeMs: Date.now(),
|
||||
valueText: '',
|
||||
valueNum: Math.max(0, Number(apiData.messagesCount || 0)),
|
||||
storagePwd,
|
||||
});
|
||||
} catch (readStateError) {
|
||||
showStatus(toUserMessage(readStateError, 'Подписка выполнена, но не удалось сохранить, сколько сообщений уже прочитано.'));
|
||||
}
|
||||
|
||||
const feed = await authService.listSubscriptionsFeed(login, 200);
|
||||
if (disposed) return;
|
||||
setChannelsFeed(feed, state.channelsIndex);
|
||||
|
||||
Reference in New Issue
Block a user