mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Stopped clearing satellite entries on each TLE update #39
This commit is contained in:
1 parent
9199765c61
commit
bf1ce64553
4 files changed
+5
-14
No files matched your search
@@ -26,7 +26,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.rtbishop.look4sat.data.*
|
||||
import com.rtbishop.look4sat.repo.EntriesRepo
|
||||
import com.rtbishop.look4sat.repo.DefaultSourcesRepo
|
||||
import com.rtbishop.look4sat.repo.SourcesRepo
|
||||
import com.rtbishop.look4sat.repo.TransmittersRepo
|
||||
import com.rtbishop.look4sat.utility.PassPredictor
|
||||
import com.rtbishop.look4sat.utility.PrefsManager
|
||||
@@ -40,7 +40,7 @@ import javax.inject.Inject
|
||||
@HiltViewModel
|
||||
class SharedViewModel @Inject constructor(
|
||||
private val prefsManager: PrefsManager,
|
||||
private val sourcesRepo: DefaultSourcesRepo,
|
||||
private val sourcesRepo: SourcesRepo,
|
||||
private val entriesRepo: EntriesRepo,
|
||||
private val transmittersRepo: TransmittersRepo
|
||||
) : ViewModel() {
|
||||
|
||||
@@ -49,7 +49,7 @@ class EntriesRepo @Inject constructor(
|
||||
resolver.openInputStream(fileUri)?.use { stream ->
|
||||
val importedEntries = TLE.importSat(stream).map { SatEntry(it) }
|
||||
val selection = entriesDao.getEntriesSelection()
|
||||
entriesDao.updateEntries(importedEntries)
|
||||
entriesDao.insertEntries(importedEntries)
|
||||
entriesDao.updateEntriesSelection(selection)
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class EntriesRepo @Inject constructor(
|
||||
importedEntries.addAll(entries)
|
||||
}
|
||||
val selection = entriesDao.getEntriesSelection()
|
||||
entriesDao.updateEntries(importedEntries)
|
||||
entriesDao.insertEntries(importedEntries)
|
||||
entriesDao.updateEntriesSelection(selection)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import com.rtbishop.look4sat.data.TleSource
|
||||
import com.rtbishop.look4sat.repo.local.SourcesDao
|
||||
import javax.inject.Inject
|
||||
|
||||
class DefaultSourcesRepo @Inject constructor(private val sourcesDao: SourcesDao) {
|
||||
class SourcesRepo @Inject constructor(private val sourcesDao: SourcesDao) {
|
||||
|
||||
fun getSources(): LiveData<List<TleSource>> {
|
||||
return sourcesDao.getSources()
|
||||
@@ -29,15 +29,6 @@ interface EntriesDao {
|
||||
@Query("SELECT * FROM entries ORDER BY name ASC")
|
||||
fun getEntries(): LiveData<List<SatEntry>>
|
||||
|
||||
@Transaction
|
||||
suspend fun updateEntries(entries: List<SatEntry>) {
|
||||
clearEntries()
|
||||
insertEntries(entries)
|
||||
}
|
||||
|
||||
@Query("DELETE FROM entries")
|
||||
suspend fun clearEntries()
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertEntries(entries: List<SatEntry>)
|
||||
|
||||
|
||||
Reference in new issue
Block a user