Use generic favorites API for pinned calendar events

This commit is contained in:
MM20 2022-10-15 15:19:56 +02:00
parent c47a880d72
commit 8597b7ab49
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 5 additions and 13 deletions

View File

@ -36,7 +36,6 @@ interface FavoritesRepository {
): Flow<List<PinnableSearchable>>
fun getPinnedCalendarEvents(): Flow<List<PinnableSearchable>>
fun getHiddenCalendarEventKeys(): Flow<List<String>>
fun isPinned(searchable: PinnableSearchable): Flow<Boolean>
fun pinItem(searchable: PinnableSearchable)
@ -134,17 +133,6 @@ internal class FavoritesRepositoryImpl(
}
}
override fun getPinnedCalendarEvents(): Flow<List<CalendarEvent>> {
return database.searchDao().getFavoritesWithTypes(
includeTypes = listOf("calendar"),
automaticallySorted = true,
manuallySorted = true,
limit = 50
).map {
it.mapNotNull { fromDatabaseEntity(it).searchable as? CalendarEvent }
}
}
override fun getHiddenCalendarEventKeys(): Flow<List<String>> {
return database.searchDao().getHiddenCalendarEventKeys()
}

View File

@ -35,7 +35,11 @@ class CalendarWidgetVM : ViewModel(), KoinComponent {
val calendarEvents = MutableLiveData<List<CalendarEvent>>(emptyList())
val pinnedCalendarEvents =
favoritesRepository.getPinnedCalendarEvents().asLiveData(viewModelScope.coroutineContext)
favoritesRepository.getFavorites(
includeTypes = listOf(CalendarEvent.Domain),
automaticallySorted = true,
manuallySorted = true,
).asLiveData(viewModelScope.coroutineContext)
val nextEvents = MutableLiveData<List<CalendarEvent>>(emptyList())
var availableDates = listOf(LocalDate.now())