mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 11:48:51 +03:00
Add error state
This commit is contained in:
parent
f5151463e2
commit
05aff3314d
3 changed files with 12 additions and 5 deletions
|
@ -36,6 +36,7 @@ interface InitialSyncProgressService {
|
|||
val rooms: Int,
|
||||
val toDevice: Int
|
||||
) : IncrementalSyncStatus()
|
||||
object IncrementalSyncError : IncrementalSyncStatus()
|
||||
object IncrementalSyncDone : IncrementalSyncStatus()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,11 +131,16 @@ internal class DefaultSyncTask @Inject constructor(
|
|||
initialSyncProgressService.endAll()
|
||||
} else {
|
||||
initialSyncProgressService.setStatus(InitialSyncProgressService.Status.IncrementalSyncIdle)
|
||||
val syncResponse = executeRequest(globalErrorReceiver) {
|
||||
syncAPI.sync(
|
||||
params = requestParams,
|
||||
readTimeOut = readTimeOut
|
||||
)
|
||||
val syncResponse = try {
|
||||
executeRequest(globalErrorReceiver) {
|
||||
syncAPI.sync(
|
||||
params = requestParams,
|
||||
readTimeOut = readTimeOut
|
||||
)
|
||||
}
|
||||
} catch (throwable: Throwable) {
|
||||
initialSyncProgressService.setStatus(InitialSyncProgressService.Status.IncrementalSyncError)
|
||||
throw throwable
|
||||
}
|
||||
initialSyncProgressService.setStatus(InitialSyncProgressService.Status.IncrementalSyncParsing(
|
||||
rooms = syncResponse.rooms?.invite.orEmpty().size + syncResponse.rooms?.join.orEmpty().size + syncResponse.rooms?.leave.orEmpty().size,
|
||||
|
|
|
@ -75,6 +75,7 @@ class SyncStateView @JvmOverloads constructor(context: Context, attrs: Attribute
|
|||
return when (this) {
|
||||
InitialSyncProgressService.Status.IncrementalSyncIdle -> "Idle"
|
||||
is InitialSyncProgressService.Status.IncrementalSyncParsing -> "Parsing ${this.rooms} room(s) ${this.toDevice} toDevice(s)"
|
||||
InitialSyncProgressService.Status.IncrementalSyncError -> "Error"
|
||||
InitialSyncProgressService.Status.IncrementalSyncDone -> "Done"
|
||||
else -> "?"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue