detail: soft delete via deletedAt i.p.v. syncStatus
This commit is contained in:
parent
143572bc81
commit
b043a5c1d2
1 changed files with 9 additions and 4 deletions
|
|
@ -2,8 +2,10 @@ import React, { useCallback, useState } from 'react'
|
|||
import { View, Text, StyleSheet, TouchableOpacity, Alert, ScrollView } from 'react-native'
|
||||
import { useFocusEffect } from '@react-navigation/native'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { initDatabase, getAllMeasurements, deleteMeasurement } from '../database/db'
|
||||
import { initDatabase, getAllMeasurements, setDeletedAt, removeMeasurement } from '../database/db'
|
||||
import { Measurement } from '../types'
|
||||
import { createApi } from '../sync/api'
|
||||
import { getApiConfig } from './SettingsScreen'
|
||||
|
||||
type Props = {
|
||||
navigation: any
|
||||
|
|
@ -57,10 +59,13 @@ export default function MeasurementDetailScreen({ navigation, route }: Props) {
|
|||
style: 'destructive',
|
||||
onPress: async () => {
|
||||
await initDatabase()
|
||||
await deleteMeasurement(measurementId)
|
||||
await setDeletedAt(measurementId)
|
||||
try {
|
||||
const { syncAll } = await import('../sync/syncService')
|
||||
await syncAll(new Set([measurementId]))
|
||||
const config = await getApiConfig()
|
||||
if (config) {
|
||||
await createApi(config).deleteMeasurement(measurementId)
|
||||
await removeMeasurement(measurementId)
|
||||
}
|
||||
} catch {}
|
||||
navigation.goBack()
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue