mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-12 05:49:30 +02:00
Separates init and restart from observables.
This commit is contained in:
parent
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()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user