mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-22 02:52:37 -05:00
alerts
This commit is contained in:
1 parent
df96aa2481
commit
5c3d5dab77
3 files changed
+5
-10
No files matched your search
+1
-7
@@ -1,7 +1,6 @@
|
||||
package com.pranshulgg.weather_master_app.data.repository
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.room.Transaction
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.AppException
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.airquality.AirQuality
|
||||
@@ -14,7 +13,6 @@ import com.pranshulgg.weather_master_app.core.model.sources.WeatherSource
|
||||
import com.pranshulgg.weather_master_app.core.network.sources.address.nominatim.json.NominatimRepository
|
||||
import com.pranshulgg.weather_master_app.data.local.dao.airquality.AirQualityDao
|
||||
import com.pranshulgg.weather_master_app.data.local.dao.location.LocationsDao
|
||||
import com.pranshulgg.weather_master_app.data.local.entity.alerts.AlertEntity
|
||||
import com.pranshulgg.weather_master_app.data.local.mapper.airquality.toDomain
|
||||
import com.pranshulgg.weather_master_app.data.local.mapper.alerts.toDomain
|
||||
import com.pranshulgg.weather_master_app.data.local.mapper.locations.toDomain
|
||||
@@ -27,11 +25,9 @@ import com.pranshulgg.weather_master_app.feature.intro.toDomain
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import jakarta.inject.Inject
|
||||
import kotlinx.coroutines.CancellableContinuation
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.time.ZoneId
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
@@ -216,9 +212,7 @@ class LocationsRepository @Inject constructor(
|
||||
.map { list -> list.map { it.toDomain() } }
|
||||
}
|
||||
|
||||
fun getAllLocationsAlerts(): Flow<List<Alert?>> {
|
||||
return dao.getAllLocationsAlerts().map { list -> list.map { it?.toDomain() } }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -14,7 +14,6 @@ import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
|
||||
class IntroScreenViewModel @Inject constructor(
|
||||
val locationsRepo: LocationsRepository,
|
||||
@ApplicationContext private val context: Context,
|
||||
|
||||
+4
-2
@@ -10,6 +10,7 @@ import com.pranshulgg.weather_master_app.core.model.domain.AppException
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.location.Location
|
||||
import com.pranshulgg.weather_master_app.core.model.domain.toMessageRes
|
||||
import com.pranshulgg.weather_master_app.core.ui.snackbar.SnackbarManager
|
||||
import com.pranshulgg.weather_master_app.data.repository.AlertsRepository
|
||||
import com.pranshulgg.weather_master_app.data.repository.LocationsRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.CancellationException
|
||||
@@ -20,7 +21,8 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class LocationsScreenViewModel @Inject constructor(
|
||||
private val locationsRepo: LocationsRepository
|
||||
private val locationsRepo: LocationsRepository,
|
||||
private val alertsRepository: AlertsRepository
|
||||
) : ViewModel() {
|
||||
|
||||
val allLocationsWeather = locationsRepo.getWeatherForAllLocations().stateIn(
|
||||
@@ -29,7 +31,7 @@ class LocationsScreenViewModel @Inject constructor(
|
||||
initialValue = emptyList()
|
||||
)
|
||||
|
||||
val allLocationsAlerts = locationsRepo.getAllLocationsAlerts().stateIn(
|
||||
val allLocationsAlerts = alertsRepository.getAllLocationsAlerts().stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(5_000),
|
||||
initialValue = emptyList()
|
||||
|
||||
Reference in new issue
Block a user