Open
Conversation
Contributor
|
Caution Review failedFailed to post review comments 📝 WalkthroughSummary by CodeRabbit
WalkthroughMigrates IMDatabase from SQLite to GRDB with a schema/type-safe layer; converts many DB paths to GRDB Row APIs; shifts update detection to a message-centric pipeline and GUID-keyed unread state; enriches associated-message/reaction modeling; adds Swift JSON revival utilities, tests, and supporting packaging/utilities. ChangesSchema, GRDB Migration & Packaging
Row-based Access & Mapped Rows
Mapped SELECT Builders, Batching & Determinism
Message-Centric Updates & Event Pipeline
Watcher State, Subscription & Unreads
Associated-message & Reaction Model
Client-side Swift JSON Revival & Tests
Utilities, Tests & Misc
Sequence Diagram(s)sequenceDiagram
participant DB as IMDatabase
participant EW as EventWatcher
participant EU as EventWatcher+Updates
participant PA as PlatformAPI
participant PS as PlatformSDK
EW->>DB: messageUpdateCursorSnapshot()
DB-->>EW: lastRowID, lastDateRead, lastDateEdited
EW->>DB: messages(newerThanRowID:orReadSince:orEditedSince:)
DB-->>EW: UpdatedMessagesQueryResult
EW->>EU: messageUpdateEvents(for: result)
EU->>DB: mappedMessageRows / mappedReactionRows / mappedAttachmentRows
DB-->>EU: msgRows, reactionRows, attachRows
EU->>PA: mapAndHashMessagesByRowID(msgRows, attachRows, reactionRows, currentUserID, accountID)
PA-->>EU: [rowID: [PlatformSDK.Message]]
EU->>EW: [ServerEvent] (upsert/update/delete + reactions)
EW->>PS: deliver events to connected clients
sequenceDiagram
participant Client as Client
participant API as PlatformAPI
participant WL as EventWatcherLifecycle
participant EW as EventWatcher
participant DB as IMDatabase
Client->>API: subscribeToEvents(onEvent, accountID)
API->>WL: subscribeToEvents(onEvent, accountID)
WL->>EW: attach Subscription(accountID,onEvent,...)
Client->>API: startEventWatchingFromCurrentState()
API->>DB: messageUpdateCursorSnapshot()
DB-->>API: cursor (lastRowID,lastDateRead,lastDateEdited)
API->>WL: startEventWatchingFromCurrentState(lastRowID,lastDateRead,lastDateEdited)
WL->>EW: startWatching(subscription,lastRowID,lastDateRead,lastDateEdited)
EW->>EW: collectMessageUpdateEvents()
EW-->>Client: push ServerEvent via onEvent
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
fe0c7dd to
c0591b6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This consolidates Messages
chat.dbaccess behind GRDB. It models Apple's tables/columns in Swift, keeps runtime guards for OS-specific optional columns, and replaces the custom SQLite statement/cache layer withDatabaseQueue,FetchableRecord, and shared row decoding. The update watcher also does more targeted message/reaction/read-state refreshes, and the hot mapped-message paths batch/dedupe lookups with targeted indexes where available.How it works:
chat.dbthrough a read-onlyDatabaseQueue.TableRecords and columns asColumnExpressionenums.TableSchemachecks before touching Apple columns that vary across OS versions.FetchableRecord/DatabaseValueConvertibleand central row helpers.Validation:
swift build --target IMDatabaseswift test --filter MessageMapperFixtureTestsswift test --filter HashingTestsyarn test:js src/swift-json.test.ts --runInBandswift testbuilds, then the local SwiftPM test runner exits with signal 11 afterEmojiSPITests.swift:31reports.nilResponse(method: "initWithLocale:").