mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Perform an initial sync after un-ignoring a user (#3439)
This commit is contained in:
parent
1b95cd537b
commit
6d741c3844
3 changed files with 16 additions and 2 deletions
|
@ -25,4 +25,5 @@ import im.vector.app.core.platform.VectorViewEvents
|
||||||
sealed class IgnoredUsersViewEvents : VectorViewEvents {
|
sealed class IgnoredUsersViewEvents : VectorViewEvents {
|
||||||
data class Loading(val message: CharSequence? = null) : IgnoredUsersViewEvents()
|
data class Loading(val message: CharSequence? = null) : IgnoredUsersViewEvents()
|
||||||
data class Failure(val throwable: Throwable) : IgnoredUsersViewEvents()
|
data class Failure(val throwable: Throwable) : IgnoredUsersViewEvents()
|
||||||
|
object Success : IgnoredUsersViewEvents()
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,14 @@ class IgnoredUsersViewModel @AssistedInject constructor(
|
||||||
private fun handleUnIgnore(action: IgnoredUsersAction.UnIgnore) {
|
private fun handleUnIgnore(action: IgnoredUsersAction.UnIgnore) {
|
||||||
setState { copy(isLoading = true) }
|
setState { copy(isLoading = true) }
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val result = runCatching { session.unIgnoreUserIds(listOf(action.userId)) }
|
val viewEvent = try {
|
||||||
|
session.unIgnoreUserIds(listOf(action.userId))
|
||||||
|
IgnoredUsersViewEvents.Success
|
||||||
|
} catch (throwable: Throwable) {
|
||||||
|
IgnoredUsersViewEvents.Failure(throwable)
|
||||||
|
}
|
||||||
setState { copy(isLoading = false) }
|
setState { copy(isLoading = false) }
|
||||||
result.onFailure { _viewEvents.post(IgnoredUsersViewEvents.Failure(it)) }
|
_viewEvents.post(viewEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ import im.vector.app.core.extensions.cleanup
|
||||||
import im.vector.app.core.extensions.configureWith
|
import im.vector.app.core.extensions.configureWith
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
import im.vector.app.databinding.FragmentGenericRecyclerBinding
|
import im.vector.app.databinding.FragmentGenericRecyclerBinding
|
||||||
|
import im.vector.app.features.MainActivity
|
||||||
|
import im.vector.app.features.MainActivityArgs
|
||||||
import im.vector.app.features.analytics.plan.MobileScreen
|
import im.vector.app.features.analytics.plan.MobileScreen
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -60,10 +62,16 @@ class VectorSettingsIgnoredUsersFragment @Inject constructor(
|
||||||
when (it) {
|
when (it) {
|
||||||
is IgnoredUsersViewEvents.Loading -> showLoading(it.message)
|
is IgnoredUsersViewEvents.Loading -> showLoading(it.message)
|
||||||
is IgnoredUsersViewEvents.Failure -> showFailure(it.throwable)
|
is IgnoredUsersViewEvents.Failure -> showFailure(it.throwable)
|
||||||
|
IgnoredUsersViewEvents.Success -> handleSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleSuccess() {
|
||||||
|
// A user has been un-ignored, perform a initial sync
|
||||||
|
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true))
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
ignoredUsersController.callback = null
|
ignoredUsersController.callback = null
|
||||||
views.genericRecyclerView.cleanup()
|
views.genericRecyclerView.cleanup()
|
||||||
|
|
Loading…
Reference in a new issue