This document explains the sync logic used in the trace mobile app.
...
Syncing in the trace mobile app is the process that updates the data between the trance mobile app and the trance backend. Since the app supports offline features we have to update new data from the app to the backend and vice versa.
...
Sync types
Sync types are defined with which types of data are syncing.
Company details
project Project details
New farmers
New cards
Buy transactions
Send transactions
Transaction invoices
Updated farmers
Product list
Buyer list
Farmer list
Transaction list
Batch list
...
Sync variables
Sync variables are the redux variables state used to track sync process and used as universal variables variable that can access anywhere from the app.
...
syncStage
- current sync stage value - initial value is 0.syncInProgress
- boolean value show that syncing is on progress or not - initial value is false.syncSuccessfull
- boolean value show that current syncing is successfully completed not.
...
Sync stages
Syncing is done with 3 different stages.
...
Stage 1: Initial sync
Stage 2: Transaction sync
Stage 3: Normal sync
1. Initial sync
Initial sync is happens on onboarding screen and it starts after login and user details APIs.
...
Then syncStage
is updated to 2, syncInProgress
to false and, syncSuccessfull
to true.
1. Company details:
Fetching Getting company details from server side and updated the API response is saved in userCompanyDetails
redux state.
2. Project details:
Getting project details from server side and API response is saved in userProjectDetails
redux state. Also updating project premium table from premiums
in this api response.
3. New farmers:
Syncing newly added farmers from app to server side.
4. New cards:
Syncing newly added cards from app to server side.
5. Buy transactions:
Syncing newly added buy transactions from app to server side.
6. Send transactions:
Syncing newly added buy transactions from app to server side.
7. Transaction invoices:
If the transaction verification method is manual then transaction invoice need to sync from app to server side.
8. Updated farmers:
Syncing updated farmer from app to server side.
9. Product list:
Syncing product list and updates from server side to app.
10. Buyer list:
Syncing buyer list and updates from server side to app.
11. Farmer list:
Syncing farmer list and updates from server side to app.
2. Transaction sync
Transaction sync happens when user on dashboard after login. syncStage
will be 2, transaction list and batch list will be synced from server side to app.
After transaction sync, syncStage
will be updated to 3. Syncing progress can be see in transaction list page.
1. Transaction list:
Syncing transaction list and updates from server side to app.
2. Batch list
Syncing batch list and updates from server side to app.