mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
fix(desktop): retain live rows after window exhaustion (#1810)
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
@@ -154,7 +154,7 @@ test("live backdated rows stay outside pages and render in order", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("live rows below the oldest retained boundary wait for paging", () => {
|
||||
test("live rows below an open oldest boundary wait for paging", () => {
|
||||
const store = replaceNewestChannelWindow(
|
||||
emptyChannelWindowStore(),
|
||||
page(null, [event("n", 110), event("a", 100)]),
|
||||
@@ -162,6 +162,30 @@ test("live rows below the oldest retained boundary wait for paging", () => {
|
||||
assert.equal(mergeLiveChannelWindowEvent(store, event("old", 90)), store);
|
||||
});
|
||||
|
||||
test("same-second live rows enter an exhausted short window regardless of id order", () => {
|
||||
const store = replaceNewestChannelWindow(
|
||||
emptyChannelWindowStore(),
|
||||
page(null, [event("a", 100), event("m", 100)], { hasMore: false }),
|
||||
);
|
||||
const live = event("z", 100);
|
||||
const withLive = mergeLiveChannelWindowEvent(store, live);
|
||||
|
||||
assert.notEqual(withLive, store);
|
||||
assert.deepEqual(
|
||||
flattenChannelWindowEvents(withLive).map((item) => item.content),
|
||||
["z", "m", "a"],
|
||||
);
|
||||
});
|
||||
|
||||
test("older live rows stay below an exhausted window", () => {
|
||||
const store = replaceNewestChannelWindow(
|
||||
emptyChannelWindowStore(),
|
||||
page(null, [event("a", 100)], { hasMore: false }),
|
||||
);
|
||||
|
||||
assert.equal(mergeLiveChannelWindowEvent(store, event("old", 99)), store);
|
||||
});
|
||||
|
||||
test("live aux stays separate from authoritative page closure", () => {
|
||||
const store = replaceNewestChannelWindow(
|
||||
emptyChannelWindowStore(),
|
||||
|
||||
@@ -178,7 +178,7 @@ export function mergeLiveThreadSummary(
|
||||
|
||||
/**
|
||||
* Merge a live top-level event without mutating authoritative page boundaries.
|
||||
* Events below the oldest loaded boundary wait for ordinary relay pagination.
|
||||
* Events below an open oldest boundary wait for ordinary relay pagination.
|
||||
*/
|
||||
export function mergeLiveChannelWindowEvent(
|
||||
current: ChannelWindowStore,
|
||||
@@ -205,7 +205,13 @@ export function mergeLiveChannelWindowEvent(
|
||||
}
|
||||
const oldestPage = current.pages[current.pages.length - 1];
|
||||
const oldest = oldestPage?.rows[oldestPage.rows.length - 1]?.event;
|
||||
if (oldest && compareRelayOrder(event, oldest) >= 0) return current;
|
||||
if (
|
||||
oldest &&
|
||||
(event.created_at < oldest.created_at ||
|
||||
(oldestPage.hasMore && compareRelayOrder(event, oldest) >= 0))
|
||||
) {
|
||||
return current;
|
||||
}
|
||||
return {
|
||||
...current,
|
||||
liveOverlay: current.liveOverlay
|
||||
|
||||
Reference in New Issue
Block a user