Store chat.db timestamps as Int64 instead of Date.#91
Conversation
|
| } | ||
|
|
||
| guard let targetDate = message.date else { | ||
| guard let targetDateNanoseconds = message.dateNanosecondsSinceReferenceDate else { |
There was a problem hiding this comment.
Bogus-date short-circuit weakened: Previously this guard used message.date, which was nil both for date <= 0 and for values that mapped past .distantFuture (the defensive clamp added in Column+.imCoreDate). After this PR, message.dateNanosecondsSinceReferenceDate is only nil for date <= 0 — the distant-future check now lives on the computed Message.date accessor and never gates this code path.
Concrete consequence: if a parent message has a malformed/extreme date value (the case the comment calls 'rare/impossible'), this function previously logged target's parent message has no date and returned nil. Now it issues messages(in: chat, filter: .before(nanosecondsSinceReferenceDate: HUGE), ...) (returns the most recent N messages — unrelated to the target) and .after(...) (returns nothing), then happily picks an arbitrary 'closest' selectable part anchored to garbage.
Probably unreachable today, but it removes the defensive behavior the comment relies on. Consider either guarding on message.date != nil here, or letting imCoreDateNanoseconds() apply the same distant-future rejection so the raw field stays in sync with the computed one.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📜 Recent review details🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-05-03T17:00:19.662ZApplied to files:
🪛 SwiftLint (0.63.2)src/IMessage/Sources/IMDatabase/Database/IMDatabase+Messages.swift[Warning] 100-100: Magic numbers should be replaced by named constants (no_magic_numbers) [Warning] 101-101: Magic numbers should be replaced by named constants (no_magic_numbers) 🔇 Additional comments (8)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR migrates message timestamp handling from ChangesMessage timestamp storage and querying migration
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
No description provided.