fix: finalize market alignment release
This commit is contained in:
@@ -99,39 +99,10 @@ export interface MarketTableDom {
|
||||
rows: MarketRowDom[];
|
||||
}
|
||||
|
||||
export interface MarketAlignmentDiagnostic {
|
||||
authorId: string;
|
||||
authorName: string;
|
||||
checkboxTop: number;
|
||||
rowTop: number;
|
||||
topDelta: number;
|
||||
}
|
||||
|
||||
export function syncMarketTable(root: ParentNode): MarketTableDom | null {
|
||||
return syncSyntheticMarketTable(root) ?? syncDivGridMarketTable(root);
|
||||
}
|
||||
|
||||
export function readMarketAlignmentDiagnostics(
|
||||
table: MarketTableDom
|
||||
): MarketAlignmentDiagnostic[] {
|
||||
return table.rows.map((rowDom) => {
|
||||
const selectionCell = rowDom.selectionCheckbox.parentElement;
|
||||
const selectionRect = selectionCell?.getBoundingClientRect();
|
||||
const rowRect = rowDom.row.getBoundingClientRect();
|
||||
|
||||
const checkboxTop = selectionRect?.top ?? Number.NaN;
|
||||
const rowTop = rowRect.top ?? Number.NaN;
|
||||
|
||||
return {
|
||||
authorId: rowDom.authorId,
|
||||
authorName: rowDom.authorName,
|
||||
checkboxTop,
|
||||
rowTop,
|
||||
topDelta: checkboxTop - rowTop
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function readMarketPageSignature(root: ParentNode): string {
|
||||
const document = getOwnerDocument(root);
|
||||
const explicitPageIndex =
|
||||
|
||||
@@ -4,7 +4,6 @@ import { createBatchPayload, type BatchPayload } from "./batch-payload";
|
||||
import {
|
||||
applyRowOrder,
|
||||
applyRowVisibility,
|
||||
readMarketAlignmentDiagnostics,
|
||||
readMarketPageSignature,
|
||||
renderMarketRowState,
|
||||
syncPluginSortHeaders,
|
||||
@@ -397,7 +396,6 @@ export function createMarketController(options: CreateMarketControllerOptions) {
|
||||
applyRowOrder(table, records.map((record) => record.authorId));
|
||||
bindSelectionControls(table);
|
||||
syncMarketSelectionState(table, selectedAuthorIds);
|
||||
logMarketAlignmentDiagnosticsIfEnabled(options.window, table, "applyCurrentView");
|
||||
lastKnownPageSignature = readMarketPageSignature(options.document);
|
||||
});
|
||||
}
|
||||
@@ -664,23 +662,12 @@ export function createMarketController(options: CreateMarketControllerOptions) {
|
||||
}
|
||||
|
||||
const step = Math.max(scrollContainer.clientHeight, 240);
|
||||
logMarketScrollTraceIfEnabled(options.window, {
|
||||
event: "start",
|
||||
maxScrollTop,
|
||||
originalScrollTop,
|
||||
step
|
||||
});
|
||||
for (
|
||||
let nextScrollTop = Math.min(originalScrollTop + step, maxScrollTop);
|
||||
nextScrollTop > originalScrollTop && nextScrollTop <= maxScrollTop;
|
||||
nextScrollTop = Math.min(nextScrollTop + step, maxScrollTop)
|
||||
) {
|
||||
setScrollTop(scrollContainer, nextScrollTop);
|
||||
logMarketScrollTraceIfEnabled(options.window, {
|
||||
event: "step",
|
||||
nextScrollTop,
|
||||
scrollTop: scrollContainer.scrollTop
|
||||
});
|
||||
hydrationSnapshot = await collectCurrentPageSnapshotsUntilSettled();
|
||||
if (
|
||||
hydrationSnapshot.missingDefaultFieldCount === 0 &&
|
||||
@@ -696,10 +683,6 @@ export function createMarketController(options: CreateMarketControllerOptions) {
|
||||
|
||||
if (scrollContainer.scrollTop !== originalScrollTop) {
|
||||
setScrollTop(scrollContainer, originalScrollTop);
|
||||
logMarketScrollTraceIfEnabled(options.window, {
|
||||
event: "restore",
|
||||
restoredScrollTop: scrollContainer.scrollTop
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1026,45 +1009,6 @@ function setScrollTop(element: HTMLElement, top: number): void {
|
||||
element.dispatchEvent(new Event("scroll"));
|
||||
}
|
||||
|
||||
function logMarketAlignmentDiagnosticsIfEnabled(
|
||||
window: Window,
|
||||
table: ReturnType<typeof syncMarketTable>,
|
||||
label: string
|
||||
): void {
|
||||
if (!isMarketDebugLoggingEnabled(window) || !table) {
|
||||
return;
|
||||
}
|
||||
|
||||
const diagnostics = readMarketAlignmentDiagnostics(table);
|
||||
console.info(`[SCES debug] ${label} alignment`, diagnostics);
|
||||
}
|
||||
|
||||
function logMarketScrollTraceIfEnabled(
|
||||
window: Window,
|
||||
payload: Record<string, unknown>
|
||||
): void {
|
||||
if (!isMarketDebugLoggingEnabled(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.info("[SCES debug] submit/export scroll", payload);
|
||||
}
|
||||
|
||||
function isMarketDebugLoggingEnabled(window: Window): boolean {
|
||||
try {
|
||||
const searchParams = new URL(window.location.href).searchParams;
|
||||
if (searchParams.get("scesDebug") === "1") {
|
||||
return true;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
return window.localStorage.getItem("scesDebugMarket") === "1";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function readCurrentPageRows(document: Document): MarketRowSnapshot[] {
|
||||
const table = syncMarketTable(document);
|
||||
if (!table) {
|
||||
|
||||
Reference in New Issue
Block a user