Frontmatter
| id | 8562 |
| title | Refactor TimelineCanvas.onTimelineDataLoad to use waitForDomRect |
| state | Closed |
| labels | airefactoring |
| assignees | tobiu |
| createdAt | Jan 11, 2026, 11:59 PM |
| updatedAt | Jan 12, 2026, 12:27 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8562 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 8398 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 12, 2026, 12:27 AM |
Refactor TimelineCanvas.onTimelineDataLoad to use waitForDomRect
tobiu assigned to @tobiu on Jan 12, 2026, 12:26 AM

tobiu
Jan 12, 2026, 12:26 AM
Input from Gemini 3 Pro:
✦ I have refactored
onTimelineDataLoadinTimelineCanvas.mjsto usewaitForDomRect.Changes:
- Replaced the manual recursive
setTimeoutlogic with a singleawait this.waitForDomRect({ attempts: 20, delay: 50, id: ids }).- Added a stale data check (
if (me.lastRecords !== records) return) to prevent race conditions from out-of-order updates.- Ensured
timelineRectis fetched (as a check) but doesn't strictly block execution if items are found, improving robustness.- Updated
onResizeto callonTimelineDataLoadwith the correct arguments (removed the unusedattemptparam).This makes the method cleaner, more robust, and fully async.
tobiu added parent issue #8398 on Jan 12, 2026, 12:26 AM
tobiu closed this issue on Jan 12, 2026, 12:27 AM
The current implementation of
onTimelineDataLoadinTimelineCanvas.mjsuses a recursive retry logic withsetTimeoutto wait for DOM elements (ticket avatars/badges) to be available. This mimics the behavior ofwaitForDomRect, but in an ad-hoc, less robust way.We should refactor this method to be
asyncand explicitly usewaitForDomRectfor the target elements. This will simplify the code, leverage the framework's built-in robust waiting mechanism, and ensure consistent behavior.Proposed Change:
onTimelineDataLoadasync.me.timeout(delay).then(...)and the retry logic with a call tome.waitForDomRect({ id: ids, attempts: 20, delay: 50 }).waitForDomRectreturns valid rects directly.Current Logic:
// If this is a fresh data load (not a resize), wait a bit for DOM let delay = attempt === 0 ? 0 : 50; me.timeout(delay).then(async () => { // ... fetch rects // ... retry if missing });New Logic (Conceptual):
async onTimelineDataLoad(records, isResize = false) { // ... (guards) let ids = records.map(r => `${r.id}-target`); let rects = await me.waitForDomRect({ id: ids, attempts: 20, delay: 50 }); // ... (process rects) }This change aligns
TimelineCanvaswith the robust pattern used elsewhere (e.g., inMainContainerController).