Do not propagate failure if saving the filter server side fails. This will be retried later.
This commit is contained in:
parent
8c111fea13
commit
1acd8e1049
|
@ -42,7 +42,7 @@ internal class DefaultGetCurrentFilterTask @Inject constructor(
|
||||||
|
|
||||||
return when (storedFilterBody) {
|
return when (storedFilterBody) {
|
||||||
currentFilterBody -> storedFilterId ?: storedFilterBody
|
currentFilterBody -> storedFilterId ?: storedFilterBody
|
||||||
else -> saveFilter(currentFilter)
|
else -> saveFilter(currentFilter) ?: currentFilterBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.session.filter
|
package org.matrix.android.sdk.internal.session.filter
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||||
import org.matrix.android.sdk.internal.network.executeRequest
|
import org.matrix.android.sdk.internal.network.executeRequest
|
||||||
|
@ -24,8 +25,9 @@ import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a filter, in db and if any changes, upload to the server.
|
* Save a filter, in db and if any changes, upload to the server.
|
||||||
|
* Return the filterId if uploading to the server is successful, else return null.
|
||||||
*/
|
*/
|
||||||
internal interface SaveFilterTask : Task<SaveFilterTask.Params, String> {
|
internal interface SaveFilterTask : Task<SaveFilterTask.Params, String?> {
|
||||||
|
|
||||||
data class Params(
|
data class Params(
|
||||||
val filter: Filter
|
val filter: Filter
|
||||||
|
@ -39,18 +41,20 @@ internal class DefaultSaveFilterTask @Inject constructor(
|
||||||
private val globalErrorReceiver: GlobalErrorReceiver,
|
private val globalErrorReceiver: GlobalErrorReceiver,
|
||||||
) : SaveFilterTask {
|
) : SaveFilterTask {
|
||||||
|
|
||||||
override suspend fun execute(params: SaveFilterTask.Params): String {
|
override suspend fun execute(params: SaveFilterTask.Params): String? {
|
||||||
val filter = params.filter
|
val filter = params.filter
|
||||||
val filterResponse = executeRequest(globalErrorReceiver) {
|
val filterResponse = tryOrNull {
|
||||||
// TODO auto retry
|
executeRequest(globalErrorReceiver) {
|
||||||
filterAPI.uploadFilter(userId, filter)
|
filterAPI.uploadFilter(userId, filter)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val filterId = filterResponse?.filterId
|
||||||
filterRepository.storeSyncFilter(
|
filterRepository.storeSyncFilter(
|
||||||
filter = filter,
|
filter = filter,
|
||||||
filterId = filterResponse.filterId,
|
filterId = filterId.orEmpty(),
|
||||||
roomEventFilter = FilterFactory.createDefaultRoomFilter()
|
roomEventFilter = FilterFactory.createDefaultRoomFilter()
|
||||||
)
|
)
|
||||||
return filterResponse.filterId
|
return filterId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue