mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 13:08:21 +01:00
Avoid deleting luckynumber when SDK returns null (#2391)
This commit is contained in:
parent
8324a9cac3
commit
9dee7f01f6
@ -35,12 +35,15 @@ class LuckyNumberRepository @Inject constructor(
|
|||||||
fetch = {
|
fetch = {
|
||||||
sdk.init(student).getLuckyNumber(student.schoolShortName)?.mapToEntity(student)
|
sdk.init(student).getLuckyNumber(student.schoolShortName)?.mapToEntity(student)
|
||||||
},
|
},
|
||||||
saveFetchResult = { old, new ->
|
saveFetchResult = { oldLuckyNumber, newLuckyNumber ->
|
||||||
if (new != old) {
|
newLuckyNumber ?: return@networkBoundResource
|
||||||
old?.let { luckyNumberDb.deleteAll(listOfNotNull(it)) }
|
|
||||||
luckyNumberDb.insertAll(listOfNotNull((new?.apply {
|
if (newLuckyNumber != oldLuckyNumber) {
|
||||||
if (notify) isNotified = false
|
val updatedLuckNumberList =
|
||||||
})))
|
listOf(newLuckyNumber.apply { if (notify) isNotified = false })
|
||||||
|
|
||||||
|
oldLuckyNumber?.let { luckyNumberDb.deleteAll(listOfNotNull(it)) }
|
||||||
|
luckyNumberDb.insertAll(updatedLuckNumberList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user