feat(mobile): offline-first post feed with SQLite cache, background sync, and optimistic post creation#614
Open
Adeolu01 wants to merge 1 commit into
Open
Conversation
…and optimistic posts
|
@Adeolu01 is attempting to deploy a commit to the Jaja's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Resolve the conflicts @Adeolu01 |
Contributor
|
@Adeolu01 Resolve the conflicts |
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.
closes #570
Summary
Implements an offline-first feed layer for the mobile app so the Feed screen
renders instantly from a local cache, posts can be created while offline and
synced when connectivity resumes, and optimistic posts that fail to confirm are
surfaced for retry or reconciled against the indexer.
The feature is fully self-contained under
apps/mobile/src/; no existingscreens, hooks, or components were modified.
What's included
SQLite cache (
apps/mobile/src/db/)linkora.dbschema with theposts,pending_posts, andfeed_cursortables as specified.
PostRepositoryexposingupsert,getPage(offset, limit),getPending,markSynced(local_id, contract_id), andmarkFailed(local_id, error), pluscursor and idempotency helpers.
PostStoreinterface:SqlitePostStore(production) andMemoryPostStore(fallback for web/tests).expo-sqliteis loaded lazily and adapts both the modern async and theSDK-49 callback APIs, falling back to in-memory storage when the native
module is unavailable.
Background sync (
apps/mobile/src/sync/feedSync.ts)FeedSyncServicefetches new posts sincefeed_cursor, upserts them, andadvances the cursor (cursor-based, never a full re-fetch). An empty response
never resets progress.
syncStarted,syncCompleted, andsyncFailedevents for the Feedscreen; concurrent syncs are coalesced.
expo-background-fetch/expo-task-managerat a 15-minute interval, guarded so non-nativeenvironments are a no-op.
Optimistic post creation and conflict resolution
pending_postsimmediately (for a "sending…"card) and submitted on chain in the background via an injected submit
function; on success they are promoted to
postsunder the contract-assignedid, on failure marked
failedfor the retry UI.(author + content within a 24h window) so already-confirmed posts are marked
synced without re-submitting.
useOfflineFeedhook composes the repository and sync service for acache-first Feed screen.
Tests
Adds 23 tests covering: feed renders from cache when offline, optimistic post
appears immediately and transitions to confirmed, failed post shows retry and
re-submits, and cursor-based incremental sync. All existing mobile tests
continue to pass (17 suites, 81 tests, 16 snapshots).
Notes
Adds
expo-sqlite,expo-background-fetch, andexpo-task-manager(Expo SDK49 compatible) to the mobile package, and includes
src/**in the mobiletsconfig.