Skip to content

Colota - Android GPS Location tracker

Simplify retry settings and fix offline sync bug

Max Dietrich3298817c4ca8
diff --git a/apps/docs/docs/api-reference.md b/apps/docs/docs/api-reference.md
index 06c7ade7..86f08058 100644
--- a/apps/docs/docs/api-reference.md
+++ b/apps/docs/docs/api-reference.md
@@ -96,11 +96,11 @@ Your server only needs to return a 2xx status code. The response body is not rea
## Error Handling
-| Error Type | Behavior |
-| ------------------------ | ----------------------------------------------------------------------------------------- |
-| **Any non-2xx response** | Queued for retry with exponential backoff |
-| **Network timeout** | Retried with backoff (10s connection, 10s read timeout) |
-| **Max retries exceeded** | Item removed from queue (location data remains in the database and can still be exported) |
+| Error Type | Behavior |
+| --- | --- |
+| **Any non-2xx response** | Queued for retry with exponential backoff |
+| **Network timeout** | Retried with backoff (10s connection, 10s read timeout) |
+| **Max retries exceeded** | Item permanently deleted from queue (location data remains in the database and can still be exported). Enable "Retry Failed Uploads" to retry indefinitely instead. |
There is no distinction between 4xx and 5xx in retry behavior — all failures are retried.
@@ -114,7 +114,7 @@ Attempt 4: +300s delay (5 minutes)
Attempt 5+: +900s delay (15 minutes)
```
-After max retries (default: 5), failed items are removed from the sync queue. The location data is not deleted — it stays in the `locations` table and can still be exported.
+By default, failed items are permanently deleted from the sync queue after 5 failed send attempts. Enable **Retry Failed Uploads** in advanced settings to keep retrying indefinitely. Either way, the location data itself is never deleted — it stays in the `locations` table and can still be exported.
## Network Requirements
diff --git a/apps/docs/docs/configuration/server-settings.md b/apps/docs/docs/configuration/server-settings.md
index 1b3afc7a..f580b693 100644
--- a/apps/docs/docs/configuration/server-settings.md
+++ b/apps/docs/docs/configuration/server-settings.md
@@ -4,13 +4,12 @@ sidebar_position: 3
# Server Settings
-| Setting | Description | Default | Range |
-| -------------- | ----------------------------------- | --------------- | ------------ |
-| Endpoint | HTTPS URL of your server | Empty (offline) | -- |
-| Sync Interval | Batch mode interval | Instant (0) | 0s -- 60min |
-| Retry Interval | Time between retry attempts | 30 seconds | 30s -- 15min |
-| Max Retries | Maximum retry attempts per location | 5 | 3, 5, 10, ∞ |
-| Offline Mode | Disable all network activity | Disabled | On/Off |
+| Setting | Description | Default | Range |
+| -------------------- | ----------------------------------------- | --------------- | ----------- |
+| Endpoint | HTTPS URL of your server | Empty (offline) | -- |
+| Sync Interval | Batch mode interval | Instant (0) | 0s -- 15min |
+| Retry Failed Uploads | Keep retrying failed uploads indefinitely | Off | On/Off |
+| Offline Mode | Disable all network activity | Disabled | On/Off |
## Endpoint URL
@@ -41,4 +40,6 @@ Attempt 4: +300s (5 minutes)
Attempt 5+: +900s (15 minutes)
```
-After max retries (default: 5), failed items are automatically removed from the queue. The app also auto-syncs when network connectivity is restored.
+By default, failed uploads are **permanently deleted after 5 failed send attempts**. Enable **Retry Failed Uploads** in advanced settings to keep retrying indefinitely — failed uploads stay in the queue until they succeed. Note that this may cause queue buildup if your server is unreachable for extended periods.
+
+The app also auto-syncs when network connectivity is restored.
diff --git a/apps/docs/docs/configuration/sync-presets.md b/apps/docs/docs/configuration/sync-presets.md
index 7d2018c1..94075f37 100644
--- a/apps/docs/docs/configuration/sync-presets.md
+++ b/apps/docs/docs/configuration/sync-presets.md
@@ -4,13 +4,13 @@ sidebar_position: 1
# Sync Presets
-Colota includes built-in presets that configure tracking interval, movement threshold, sync interval, and retry behavior together.
+Colota includes built-in presets that configure tracking interval, movement threshold, and sync interval together.
-| Preset | Interval | Distance | Sync Interval | Retry Interval | Best For |
-| --------------- | -------- | -------- | ------------- | -------------- | --------------- |
-| **Instant** | 5s | 0m | Instant (0s) | 30s | City navigation |
-| **Balanced** | 30s | 1m | 5 minutes | 5 minutes | Daily commute |
-| **Power Saver** | 60s | 2m | 15 minutes | 15 minutes | Long trips |
-| **Custom** | 1s--∞ | 0m--∞ | 0s--∞ | 30s--∞ | Advanced users |
+| Preset | Interval | Distance | Sync Interval | Best For |
+| --------------- | -------- | -------- | ------------- | --------------- |
+| **Instant** | 5s | 0m | Instant (0s) | City navigation |
+| **Balanced** | 30s | 1m | 5 minutes | Daily commute |
+| **Power Saver** | 60s | 2m | 15 minutes | Long trips |
+| **Custom** | 1s--∞ | 0m--∞ | 0s--∞ | Advanced users |
Select a preset in **Settings** or choose **Custom** to configure each parameter individually.
diff --git a/apps/mobile/android/app/src/main/java/com/colota/SyncManager.kt b/apps/mobile/android/app/src/main/java/com/colota/SyncManager.kt
index a7a64ab4..2f204ee8 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/SyncManager.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/SyncManager.kt
@@ -123,7 +123,7 @@ class SyncManager(
}
// Immediate send mode (syncInterval = 0)
- if (syncIntervalSeconds == 0) {
+ if (syncIntervalSeconds == 0 && networkManager.isNetworkAvailable()) {
Log.d(TAG, "Instant send")
val success = networkManager.sendToEndpoint(payload, endpoint, authHeaders)
@@ -135,7 +135,6 @@ class SyncManager(
dbHelper.incrementRetryCount(queueId, "Send failed")
}
}
- Log.d(TAG, "Waiting for sync")
// If syncInterval > 0, the periodic sync job will handle it
}
diff --git a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
index 0418af60..8556df4d 100644
--- a/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
+++ b/apps/mobile/src/components/features/settings/SyncStrategySettings.tsx
@@ -238,85 +238,33 @@ export function SyncStrategySettings({
</View>
</View>
- {/* Retry Interval */}
- <View style={styles.settingBlock}>
- <Text style={[styles.blockLabel, { color: colors.text }]}>Retry Interval</Text>
- <Text style={[styles.blockHint, { color: colors.textSecondary }]}>
- Wait time before retrying failed uploads
- </Text>
-
- <View style={styles.optionsGrid}>
- {([30, 300, 900] as const).map((sec) => {
- const labels: Record<number, string> = {
- 30: "30s",
- 300: "5m",
- 900: "15m"
- }
- const isSelected = settings.retryInterval === sec
-
- return (
- <TouchableOpacity
- key={sec}
- style={[
- styles.gridOption,
- {
- borderColor: colors.border,
- backgroundColor: colors.background
- },
- isSelected && {
- borderColor: colors.primary,
- backgroundColor: colors.primary + "20"
- }
- ]}
- onPress={() => handleGridSelect("retryInterval", sec)}
- activeOpacity={0.7}
- >
- <Text style={[styles.gridLabel, { color: isSelected ? colors.primary : colors.text }]}>
- {labels[sec]}
- </Text>
- </TouchableOpacity>
- )
- })}
- </View>
- </View>
-
- {/* Max Retries */}
- <View style={styles.settingBlock}>
- <Text style={[styles.blockLabel, { color: colors.text }]}>Max Retry Attempts</Text>
- <View style={styles.retryGrid}>
- {[3, 5, 10, 0].map((val) => (
- <TouchableOpacity
- key={val}
- style={[
- styles.retryChip,
- {
- borderColor: colors.border,
- backgroundColor: colors.background
- },
- settings.maxRetries === val && {
- borderColor: colors.primary,
- backgroundColor: colors.primary + "20"
- }
- ]}
- onPress={() => handleGridSelect("maxRetries", val)}
- activeOpacity={0.7}
- >
- <Text
- style={[
- styles.retryChipText,
- { color: settings.maxRetries === val ? colors.primary : colors.text }
- ]}
- >
- {val === 0 ? "∞" : val}
- </Text>
- </TouchableOpacity>
- ))}
+ {/* Retry Forever Toggle */}
+ <View style={styles.settingRow}>
+ <View style={styles.settingContent}>
+ <Text style={[styles.settingLabel, { color: colors.text }]}>Retry Failed Uploads</Text>
+ <Text style={[styles.settingHint, { color: colors.textSecondary }]}>
+ {settings.maxRetries === 0
+ ? "Failed uploads stay in the queue until they succeed"
+ : "Failed uploads are permanently deleted after 5 failed send attempts"}
+ </Text>
</View>
- <Text style={[styles.blockHint, styles.retryHint, { color: colors.textSecondary }]}>
- {settings.maxRetries === 0
- ? "Unlimited retries may cause queue buildup"
- : `Give up after ${settings.maxRetries} failed attempts`}
- </Text>
+ <Switch
+ value={settings.maxRetries === 0}
+ onValueChange={(retryForever) => {
+ const next = {
+ ...settings,
+ maxRetries: retryForever ? 0 : 5,
+ syncPreset: "custom" as const
+ }
+ onSettingsChange(next)
+ onImmediateSave(next)
+ }}
+ trackColor={{
+ false: colors.border,
+ true: colors.primary + "80"
+ }}
+ thumbColor={settings.maxRetries === 0 ? colors.primary : colors.border}
+ />
</View>
</View>
@@ -458,24 +406,6 @@ const styles = StyleSheet.create({
fontSize: 14,
...fonts.semiBold
},
- retryGrid: {
- flexDirection: "row",
- gap: 10
- },
- retryChip: {
- flex: 1,
- borderWidth: 2,
- borderRadius: 10,
- paddingVertical: 12,
- alignItems: "center"
- },
- retryChipText: {
- fontSize: 16,
- ...fonts.bold
- },
- retryHint: {
- marginTop: 8
- },
settingRow: {
flexDirection: "row",
justifyContent: "space-between",
diff --git a/apps/mobile/src/types/global.ts b/apps/mobile/src/types/global.ts
index 9d30d242..3b58a405 100644
--- a/apps/mobile/src/types/global.ts
+++ b/apps/mobile/src/types/global.ts
@@ -188,7 +188,7 @@ export const TRACKING_PRESETS = {
},
balanced: {
interval: 30,
- distance: 1,
+ distance: 2,
syncInterval: 300,
retryInterval: 300,
label: "Balanced",