Show error messages on login screen

This commit is contained in:
miruka 2019-08-16 16:30:18 -04:00
parent e920299db4
commit c7adb5b02f
5 changed files with 39 additions and 10 deletions

View File

@ -41,6 +41,7 @@
- When starting a long task, e.g. importing keys, quitting the page,
and coming back, show the buttons as still loading until operation is done
- Make invite/left banners look better in column mode
- Responses
- Messages editing
- Code highlighting
- Support GIF avatars
@ -100,6 +101,7 @@
- Accent color from background
- Settings page
- Message/text selection
- Notifications
- Custom file picker for Linux...

View File

@ -49,14 +49,19 @@ class Backend:
user: str,
password: str,
device_id: Optional[str] = None,
homeserver: str = "https://matrix.org") -> str:
homeserver: str = "https://matrix.org",
) -> Tuple[bool, str]:
client = MatrixClient(
self, user=user, homeserver=homeserver, device_id=device_id,
)
try:
await client.login(password)
except RuntimeError as err:
return (False, err.args[0].message)
self.clients[client.user_id] = client
self.models[Account][client.user_id] = Account(client.user_id)
return client.user_id
return (True, client.user_id)
async def resume_client(self,

View File

@ -112,7 +112,7 @@ class MatrixClient(nio.AsyncClient):
)
if isinstance(response, nio.LoginError):
log.error(response)
raise RuntimeError(response)
else:
await self.start()
@ -497,7 +497,7 @@ class MatrixClient(nio.AsyncClient):
async def onErrorResponse(self, resp: nio.ErrorResponse) -> None:
# TODO: show something in the client
# TODO: show something in the client, must be seen on login screen too
try:
log.warning("%s - %s", resp, json.dumps(resp.__dict__, indent=4))
except Exception:

View File

@ -26,8 +26,14 @@ Item {
button.loading = true
let args = [idField.text, passwordField.text]
py.callCoro("login_client", args, userId => {
pageStack.showPage("RememberAccount", {loginWith, userId})
py.callCoro("login_client", args, ([success, data]) => {
if (success) {
// data = userId
errorMessage.text = ""
pageStack.showPage("RememberAccount", {loginWith,data})
} else {
errorMessage.text = qsTr(data)
}
button.loading = false
})
},
@ -77,5 +83,19 @@ Item {
Layout.fillWidth: true
Layout.margins: signInBox.margins
}
HLabel {
id: errorMessage
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
color: theme.colors.errorText
visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitHeight : 0
Behavior on Layout.maximumHeight { HNumberAnimation {} }
Layout.fillWidth: true
Layout.margins: signInBox.margins
}
}
}

View File

@ -53,6 +53,8 @@ colors:
color halfDimText: hsluv(0, 0, intensity * 70)
color dimText: hsluv(0, 0, intensity * 55)
color dimmerText: hsluv(0, 0, intensity * 30)
color errorText: hsluv(0, saturation * 2.25, 50)
color accentText: hsluv(hue - 80, saturation * 2.25, 60)
color link: accentText
color code: hsluv(hue + 5, saturation * 1.5, intensity * 60)