-
Notifications
You must be signed in to change notification settings - Fork 233
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
store: Handle invalid API key on register-queue #1183
base: main
Are you sure you want to change the base?
Changes from all commits
d6f69b0
2303f9e
5985410
52d1a5e
64d5e9d
90d8cb5
08e4f6a
31020b6
3d36968
3b2d9ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,8 +186,8 @@ | |
"url": {"type": "String", "example": "http://example.com/"} | ||
} | ||
}, | ||
"errorLoginCouldNotConnectTitle": "Could not connect", | ||
"@errorLoginCouldNotConnectTitle": { | ||
"errorCouldNotConnectTitle": "Could not connect", | ||
"@errorCouldNotConnectTitle": { | ||
"description": "Error title when the app could not connect to the server." | ||
}, | ||
"errorMessageDoesNotSeemToExist": "That message does not seem to exist.", | ||
|
@@ -458,6 +458,13 @@ | |
"@topicValidationErrorMandatoryButEmpty": { | ||
"description": "Topic validation error when topic is required but was empty." | ||
}, | ||
"errorInvalidApiKeyMessage": "Your account at {url} cannot be authenticated. Please try again or use another account.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think my comment in CZO still applies:
Or, from another angle: the server hasn't said that the account can't be authenticated, so we shouldn't tell the user that. That would be a pretty pathological case: I guess in theory it would be accurate if the database were corrupted in a way that made it impossible to know if any API key was valid. What we know from the
cc @alya for thoughts on this message. |
||
"@errorInvalidApiKeyMessage": { | ||
"description": "Error message in the dialog for invalid API key.", | ||
"placeholders": { | ||
"url": {"type": "String", "example": "http://chat.example.com/"} | ||
} | ||
}, | ||
"errorInvalidResponse": "The server sent an invalid response", | ||
"@errorInvalidResponse": { | ||
"description": "Error message when an API call returned an invalid response." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,8 @@ class ZulipApp extends StatefulWidget { | |
@visibleForTesting | ||
static void debugReset() { | ||
_snackBarCount = 0; | ||
reportErrorToUserBriefly = defaultReportErrorToUserBriefly; | ||
reportErrorToUserBriefly = reportErrorToConsole; | ||
reportErrorToUserModally = reportErrorToConsole; | ||
_ready.dispose(); | ||
_ready = ValueNotifier(false); | ||
} | ||
|
@@ -128,10 +129,21 @@ class ZulipApp extends StatefulWidget { | |
newSnackBar.closed.whenComplete(() => _snackBarCount--); | ||
} | ||
|
||
/// The callback we normally use as [reportErrorToUserModally]. | ||
static void _reportErrorToUserModally(String message, {String? details}) { | ||
assert(_ready.value); | ||
|
||
showErrorDialog( | ||
context: navigatorKey.currentContext!, | ||
title: message, | ||
message: details); | ||
} | ||
|
||
void _declareReady() { | ||
assert(navigatorKey.currentContext != null); | ||
_ready.value = true; | ||
reportErrorToUserBriefly = _reportErrorToUserBriefly; | ||
reportErrorToUserModally = _reportErrorToUserModally; | ||
} | ||
|
||
@override | ||
|
@@ -221,6 +233,14 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver { | |
class ChooseAccountPage extends StatelessWidget { | ||
const ChooseAccountPage({super.key}); | ||
|
||
/// Navigate to [ChooseAccountPage], ensuring that its route is at the root level. | ||
static void navigate(BuildContext context) { | ||
final navigator = Navigator.of(context); | ||
navigator.popUntil((route) => route.isFirst); | ||
unawaited(navigator.pushReplacement( | ||
MaterialWidgetRoute(page: const ChooseAccountPage()))); | ||
} | ||
Comment on lines
+236
to
+242
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this isn't used anywhere. |
||
|
||
Widget _buildAccountItem( | ||
BuildContext context, { | ||
required int accountId, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit-message nit: "generalized"