Show error messages on login screen
This commit is contained in:
parent
e920299db4
commit
c7adb5b02f
2
TODO.md
2
TODO.md
|
@ -41,6 +41,7 @@
|
||||||
- When starting a long task, e.g. importing keys, quitting the page,
|
- 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
|
and coming back, show the buttons as still loading until operation is done
|
||||||
- Make invite/left banners look better in column mode
|
- Make invite/left banners look better in column mode
|
||||||
|
- Responses
|
||||||
- Messages editing
|
- Messages editing
|
||||||
- Code highlighting
|
- Code highlighting
|
||||||
- Support GIF avatars
|
- Support GIF avatars
|
||||||
|
@ -100,6 +101,7 @@
|
||||||
- Accent color from background
|
- Accent color from background
|
||||||
- Settings page
|
- Settings page
|
||||||
- Message/text selection
|
- Message/text selection
|
||||||
|
- Notifications
|
||||||
|
|
||||||
- Custom file picker for Linux...
|
- Custom file picker for Linux...
|
||||||
|
|
||||||
|
|
|
@ -46,17 +46,22 @@ class Backend:
|
||||||
# Clients management
|
# Clients management
|
||||||
|
|
||||||
async def login_client(self,
|
async def login_client(self,
|
||||||
user: str,
|
user: str,
|
||||||
password: str,
|
password: str,
|
||||||
device_id: Optional[str] = None,
|
device_id: Optional[str] = None,
|
||||||
homeserver: str = "https://matrix.org") -> str:
|
homeserver: str = "https://matrix.org",
|
||||||
|
) -> Tuple[bool, str]:
|
||||||
client = MatrixClient(
|
client = MatrixClient(
|
||||||
self, user=user, homeserver=homeserver, device_id=device_id,
|
self, user=user, homeserver=homeserver, device_id=device_id,
|
||||||
)
|
)
|
||||||
await client.login(password)
|
try:
|
||||||
|
await client.login(password)
|
||||||
|
except RuntimeError as err:
|
||||||
|
return (False, err.args[0].message)
|
||||||
|
|
||||||
self.clients[client.user_id] = client
|
self.clients[client.user_id] = client
|
||||||
self.models[Account][client.user_id] = Account(client.user_id)
|
self.models[Account][client.user_id] = Account(client.user_id)
|
||||||
return client.user_id
|
return (True, client.user_id)
|
||||||
|
|
||||||
|
|
||||||
async def resume_client(self,
|
async def resume_client(self,
|
||||||
|
|
|
@ -112,7 +112,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(response, nio.LoginError):
|
if isinstance(response, nio.LoginError):
|
||||||
log.error(response)
|
raise RuntimeError(response)
|
||||||
else:
|
else:
|
||||||
await self.start()
|
await self.start()
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
|
|
||||||
|
|
||||||
async def onErrorResponse(self, resp: nio.ErrorResponse) -> None:
|
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:
|
try:
|
||||||
log.warning("%s - %s", resp, json.dumps(resp.__dict__, indent=4))
|
log.warning("%s - %s", resp, json.dumps(resp.__dict__, indent=4))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -26,8 +26,14 @@ Item {
|
||||||
button.loading = true
|
button.loading = true
|
||||||
let args = [idField.text, passwordField.text]
|
let args = [idField.text, passwordField.text]
|
||||||
|
|
||||||
py.callCoro("login_client", args, userId => {
|
py.callCoro("login_client", args, ([success, data]) => {
|
||||||
pageStack.showPage("RememberAccount", {loginWith, userId})
|
if (success) {
|
||||||
|
// data = userId
|
||||||
|
errorMessage.text = ""
|
||||||
|
pageStack.showPage("RememberAccount", {loginWith,data})
|
||||||
|
} else {
|
||||||
|
errorMessage.text = qsTr(data)
|
||||||
|
}
|
||||||
button.loading = false
|
button.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -77,5 +83,19 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: signInBox.margins
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ colors:
|
||||||
color halfDimText: hsluv(0, 0, intensity * 70)
|
color halfDimText: hsluv(0, 0, intensity * 70)
|
||||||
color dimText: hsluv(0, 0, intensity * 55)
|
color dimText: hsluv(0, 0, intensity * 55)
|
||||||
color dimmerText: hsluv(0, 0, intensity * 30)
|
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 accentText: hsluv(hue - 80, saturation * 2.25, 60)
|
||||||
color link: accentText
|
color link: accentText
|
||||||
color code: hsluv(hue + 5, saturation * 1.5, intensity * 60)
|
color code: hsluv(hue + 5, saturation * 1.5, intensity * 60)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user