kopia lustrzana https://github.com/vitorpamplona/amethyst
Separates init and restart from observables.
rodzic
45446b4125
commit
b1399d1c13
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue