CORE/CONTENT test5593 и адаптация UI

This commit is contained in:
AidarKC
2026-11-27 00:47:13 +03:00
parent 205b7ad971
commit 873535654e
1271 changed files with 219621 additions and 1900 deletions
@@ -44,3 +44,28 @@ export function ordinalForPublication(messages, reference) {
});
return i < 0 ? null : i + 1;
}
// Read watermarks use canonical block order, not the time-sorted display ordinal.
// Require the complete list and its exact final anchor from the subscription feed.
export function canonicalReadPosts(posts, summary) {
const channel = summary?.channel, root = channel?.channelRoot;
const hash = v => typeof v === 'string' && /^[0-9a-f]{64}$/.test(v);
if (!channel?.ownerLogin || !Number.isInteger(root?.blockNumber) || !hash(root.blockHash)
|| !hash(summary.followHash) || !Number.isInteger(summary.messagesCount) || summary.messagesCount !== posts.length) return null;
const ordered = [...posts].sort((a,b) => a.messageRef?.blockNumber - b.messageRef?.blockNumber);
let previous = root.blockNumber;
const ordinals = new Set();
for (const post of ordered) {
const ref = post.messageRef;
if (String(post.authorLogin || '').toLowerCase() !== channel.ownerLogin.toLowerCase() || !Number.isInteger(ref?.blockNumber) || ref.blockNumber <= previous || !hash(ref.blockHash) || !Number.isInteger(post.localNumber) || post.localNumber <= 0 || ordinals.has(post.localNumber)) return null;
previous = ref.blockNumber; ordinals.add(post.localNumber);
}
const last = ordered.at(-1)?.messageRef || root;
if (last.blockNumber !== summary.readAnchor?.blockNumber || last.blockHash !== summary.readAnchor?.blockHash) return null;
return ordered;
}
export function readPrefixCount(ordered, alreadyRead, seenOrdinals) {
let count = Math.min(ordered.length, Math.max(0, alreadyRead));
while (count < ordered.length && seenOrdinals.has(ordered[count].localNumber)) count++;
return count;
}