Skip to content

Conversation

@najuna-brian
Copy link
Contributor

Description

Implements full local data reset when users switch Synkronus server URLs to prevent cross-server data corruption.

Changes

  • Added ServerSwitchService to orchestrate complete local state reset
  • Updated SettingsScreen to detect server URL changes and prompt user
  • Shows unsynced data counts (observations + attachments) before reset
  • Offers three options:
    • Sync then switch (recommended): Syncs all data first, then resets
    • Proceed without syncing: Immediately wipes and switches
    • Cancel: Aborts the operation

What Gets Reset

  • WatermelonDB (all observations)
  • Sync cursors (`@last_seen_version`, `@last_attachment_version`)
  • App bundle and form definitions (`/app`, `/forms`)
  • Attachment files (`/attachments`, `/attachments/pending_upload`)
  • Auth tokens and user session
  • All AsyncStorage sync/app metadata

Testing

  • ✅ Unit tests added for `ServerSwitchService`
  • ✅ All tests passing
  • ✅ Tested on device.

Resolves #109

@najuna-brian najuna-brian marked this pull request as ready for review December 22, 2025 16:22
r0ssing
r0ssing previously approved these changes Dec 22, 2025
Copy link
Contributor

@r0ssing r0ssing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Let's find a good way to solve the error handling conundrum :-)

Copy link
Contributor

@r0ssing r0ssing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Ndacyayisenga-droid Ndacyayisenga-droid merged commit 93792fb into OpenDataEnsemble:dev Dec 24, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clear WatermelonDB and reset sync state when switching Synkronus servers

3 participants