Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTUE - Single loading state #5517

Merged
merged 8 commits into from
Mar 24, 2022
1 change: 1 addition & 0 deletions changelog.d/5517.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flattening the asynchronous onboarding state and passing all errors through the same pipeline
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,36 @@ fun Throwable.getRetryDelay(defaultValue: Long): Long {
?: defaultValue
}

fun Throwable.isUsernameInUse(): Boolean {
return this is Failure.ServerError && error.code == MatrixError.M_USER_IN_USE
}

fun Throwable.isInvalidUsername(): Boolean {
return this is Failure.ServerError &&
error.code == MatrixError.M_INVALID_USERNAME
}

fun Throwable.isInvalidPassword(): Boolean {
return this is Failure.ServerError &&
error.code == MatrixError.M_FORBIDDEN &&
error.message == "Invalid password"
}

fun Throwable.isRegistrationDisabled(): Boolean {
return this is Failure.ServerError && error.code == MatrixError.M_FORBIDDEN &&
httpCode == HttpsURLConnection.HTTP_FORBIDDEN
}

fun Throwable.isWeakPassword(): Boolean {
return this is Failure.ServerError && error.code == MatrixError.M_WEAK_PASSWORD
}

fun Throwable.isLoginEmailUnknown(): Boolean {
return this is Failure.ServerError &&
error.code == MatrixError.M_FORBIDDEN &&
error.message.isEmpty()
}

fun Throwable.isInvalidUIAAuth(): Boolean {
return this is Failure.ServerError &&
error.code == MatrixError.M_FORBIDDEN &&
Expand Down Expand Up @@ -104,8 +128,8 @@ fun Throwable.isRegistrationAvailabilityError(): Boolean {
return this is Failure.ServerError &&
httpCode == HttpsURLConnection.HTTP_BAD_REQUEST && /* 400 */
(error.code == MatrixError.M_USER_IN_USE ||
error.code == MatrixError.M_INVALID_USERNAME ||
error.code == MatrixError.M_EXCLUSIVE)
error.code == MatrixError.M_INVALID_USERNAME ||
error.code == MatrixError.M_EXCLUSIVE)
}

/**
Expand Down
Loading