Merge pull request #4850 from vector-im/feature/bma/small_changes
Small changes
This commit is contained in:
commit
c836491498
|
@ -36,6 +36,7 @@ import org.matrix.android.sdk.internal.session.sync.model.accountdata.AcceptedTe
|
||||||
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
|
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
|
||||||
import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
|
import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
|
||||||
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
|
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultTermsService @Inject constructor(
|
internal class DefaultTermsService @Inject constructor(
|
||||||
|
@ -63,19 +64,28 @@ internal class DefaultTermsService @Inject constructor(
|
||||||
*/
|
*/
|
||||||
override suspend fun getHomeserverTerms(baseUrl: String): TermsResponse {
|
override suspend fun getHomeserverTerms(baseUrl: String): TermsResponse {
|
||||||
return try {
|
return try {
|
||||||
|
val request = baseUrl + NetworkConstants.URI_API_PREFIX_PATH_R0 + "register"
|
||||||
executeRequest(null) {
|
executeRequest(null) {
|
||||||
termsAPI.register(baseUrl + NetworkConstants.URI_API_PREFIX_PATH_R0 + "register")
|
termsAPI.register(request)
|
||||||
}
|
}
|
||||||
// Return empty result if it succeed, but it should never happen
|
// Return empty result if it succeed, but it should never happen
|
||||||
|
Timber.w("Request $request succeeded, it should never happen")
|
||||||
TermsResponse()
|
TermsResponse()
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
|
val registrationFlowResponse = throwable.toRegistrationFlowResponse()
|
||||||
|
if (registrationFlowResponse != null) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
TermsResponse(
|
TermsResponse(
|
||||||
policies = (throwable.toRegistrationFlowResponse()
|
policies = (registrationFlowResponse
|
||||||
?.params
|
.params
|
||||||
?.get(LoginFlowTypes.TERMS) as? JsonDict)
|
?.get(LoginFlowTypes.TERMS) as? JsonDict)
|
||||||
?.get("policies") as? JsonDict
|
?.get("policies") as? JsonDict
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
// Other error
|
||||||
|
Timber.e(throwable, "Error while getting homeserver terms")
|
||||||
|
throw throwable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ class WidgetFragment @Inject constructor() :
|
||||||
return@withState true
|
return@withState true
|
||||||
}
|
}
|
||||||
R.id.action_delete -> {
|
R.id.action_delete -> {
|
||||||
viewModel.handle(WidgetAction.DeleteWidget)
|
deleteWidget()
|
||||||
return@withState true
|
return@withState true
|
||||||
}
|
}
|
||||||
R.id.action_refresh -> if (state.formattedURL.complete) {
|
R.id.action_refresh -> if (state.formattedURL.complete) {
|
||||||
|
@ -172,7 +172,7 @@ class WidgetFragment @Inject constructor() :
|
||||||
return@withState true
|
return@withState true
|
||||||
}
|
}
|
||||||
R.id.action_revoke -> if (state.status == WidgetStatus.WIDGET_ALLOWED) {
|
R.id.action_revoke -> if (state.status == WidgetStatus.WIDGET_ALLOWED) {
|
||||||
viewModel.handle(WidgetAction.RevokeWidget)
|
revokeWidget()
|
||||||
return@withState true
|
return@withState true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ class WidgetFragment @Inject constructor() :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteWidget() {
|
private fun deleteWidget() {
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setMessage(R.string.widget_delete_message_confirmation)
|
.setMessage(R.string.widget_delete_message_confirmation)
|
||||||
.setPositiveButton(R.string.remove) { _, _ ->
|
.setPositiveButton(R.string.remove) { _, _ ->
|
||||||
|
@ -316,7 +316,7 @@ class WidgetFragment @Inject constructor() :
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun revokeWidget() {
|
private fun revokeWidget() {
|
||||||
viewModel.handle(WidgetAction.RevokeWidget)
|
viewModel.handle(WidgetAction.RevokeWidget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue