()
| 151 | * BackgroundGeolocation.sync() |
| 152 | */ |
| 153 | const sync = async () => { |
| 154 | try { |
| 155 | if (isSyncing) { |
| 156 | console.log('[FABMenu] Sync already in progress (ignored)'); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | const count = await BackgroundGeolocation.getCount(); |
| 161 | |
| 162 | if (!count) { |
| 163 | Alert.alert('Sync', 'Locations database is empty'); |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | Alert.alert( |
| 168 | 'Confirm Sync', |
| 169 | `Sync ${count} records?`, |
| 170 | [ |
| 171 | { text: 'No', style: 'cancel' }, |
| 172 | { |
| 173 | text: 'Yes', |
| 174 | onPress: async () => { |
| 175 | try { |
| 176 | setIsSyncing(true); |
| 177 | await BackgroundGeolocation.sync(); |
| 178 | console.log('[FABMenu] Sync complete'); |
| 179 | } catch (e) { |
| 180 | console.warn('[FABMenu] Sync error:', e); |
| 181 | Alert.alert('Sync error', String(e)); |
| 182 | } finally { |
| 183 | setIsSyncing(false); |
| 184 | } |
| 185 | }, |
| 186 | }, |
| 187 | ], |
| 188 | { cancelable: true } |
| 189 | ); |
| 190 | } catch (e) { |
| 191 | console.warn('[FABMenu] getCount/sync error:', e); |
| 192 | Alert.alert('Sync error', String(e)); |
| 193 | } |
| 194 | }; |
| 195 | |
| 196 | /** |
| 197 | * BackgroundGeolocation.resetOdometer() |
no test coverage detected