From 5c3d5dab77e51405daadab4e544da2fc77253352 Mon Sep 17 00:00:00 2001 From: PranshulGG Date: Wed, 29 Jul 2026 17:28:16 +0530 Subject: [PATCH] alerts --- .../data/repository/LocationsRepository.kt | 8 +------- .../feature/intro/IntroScreenViewModel.kt | 1 - .../feature/locations/LocationsScreenViewModel.kt | 6 ++++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/data/repository/LocationsRepository.kt b/app/src/main/java/com/pranshulgg/weather_master_app/data/repository/LocationsRepository.kt index 3010103f9..391195642 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/data/repository/LocationsRepository.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/data/repository/LocationsRepository.kt @@ -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> { - return dao.getAllLocationsAlerts().map { list -> list.map { it?.toDomain() } } - } + } diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/intro/IntroScreenViewModel.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/intro/IntroScreenViewModel.kt index 5bbd689de..e152ffc22 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/intro/IntroScreenViewModel.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/intro/IntroScreenViewModel.kt @@ -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, diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/locations/LocationsScreenViewModel.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/locations/LocationsScreenViewModel.kt index 101da3a5e..4f17d397a 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/locations/LocationsScreenViewModel.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/locations/LocationsScreenViewModel.kt @@ -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()