Separates init and restart from observables.

pull/983/head
Vitor Pamplona 2024-07-17 16:35:48 -04:00
rodzic 45446b4125
commit b1399d1c13
2 zmienionych plików z 16 dodań i 4 usunięć

Wyświetl plik

@ -46,7 +46,7 @@ class LatestByKindAndAuthor<T : Event>(
fun canDelete(): Boolean = _latest.subscriptionCount.value == 0
suspend fun init() {
fun restart() {
val latestNote =
if ((kind in 10000..19999) || (kind in 30000..39999)) {
LocalCache.addressables
@ -70,6 +70,12 @@ class LatestByKindAndAuthor<T : Event>(
)?.event as? T
}
_latest.tryEmit(latestNote)
if (_latest.value != latestNote) {
_latest.tryEmit(latestNote)
}
}
suspend fun init() {
restart()
}
}

Wyświetl plik

@ -45,7 +45,7 @@ class LatestByKindWithETag<T : Event>(
fun canDelete(): Boolean = _latest.subscriptionCount.value == 0
suspend fun init() {
fun restart() {
val latestNote =
LocalCache.notes
.maxOrNullOf(
@ -57,6 +57,12 @@ class LatestByKindWithETag<T : Event>(
comparator = CreatedAtComparator,
)?.event as? T
_latest.tryEmit(latestNote)
if (_latest.value != latestNote) {
_latest.tryEmit(latestNote)
}
}
suspend fun init() {
restart()
}
}