Skip to content

Commit

Permalink
log [nfc]: Revise reportErrorToUserBriefly doc; tweak related comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Sep 24, 2024
1 parent 2d5624c commit e36f984
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ bool debugLog(String message) {

typedef ReportErrorCallback = void Function(String? message, {String? details});

/// Display an error message in a [SnackBar].
/// Show the user an error message, without requiring them to interact with it.
///
/// This shows a [SnackBar] containing the message if [ZulipApp] is ready,
/// otherwise logs it to the console.
/// Typically this shows a [SnackBar] containing the message.
/// If called before the app's widget tree is ready (see [ZulipApp.ready]),
/// then we give up on showing the message to the user,
/// and just log the message to the console.
///
/// If `message` is null, this will clear the existing [SnackBar]s if there
/// are any. Useful for promptly dismissing errors.
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ class ZulipApp extends StatefulWidget {

static int _snackBarCount = 0;

/// The callback we normally use as [reportErrorToUserBriefly].
static void _reportErrorToUserBriefly(String? message, {String? details}) {
assert(_ready.value);

if (message == null) {
if (_snackBarCount == 0) return;
assert(_snackBarCount > 0);
// The snack bar API only exposes ways to hide ether the current snack
// The [SnackBar] API only exposes ways to hide ether the current snack
// bar or all of them.
//
// To reduce the possibility of hiding snack bars not created by this
Expand Down

0 comments on commit e36f984

Please sign in to comment.