Skip to content

Commit dd63732

Browse files
committed
content [nfc]: Inline showError helper in _launchUrl
Some of _launchUrl is specific to opening links in message content, but a lot is generic and could helpfully be pulled out to be reused in other places where we open links. We'll do that next; first, inline this helper function, which has one caller in the content-specific code and one in the generic code.
1 parent 2bb3c39 commit dd63732

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/widgets/content.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,20 +1414,13 @@ class MessageTableCell extends StatelessWidget {
14141414
}
14151415

14161416
void _launchUrl(BuildContext context, String urlString) async {
1417-
DialogStatus showError(BuildContext context, String? message) {
1418-
final zulipLocalizations = ZulipLocalizations.of(context);
1419-
return showErrorDialog(context: context,
1420-
title: zulipLocalizations.errorCouldNotOpenLinkTitle,
1421-
message: [
1422-
zulipLocalizations.errorCouldNotOpenLink(urlString),
1423-
if (message != null) message,
1424-
].join("\n\n"));
1425-
}
1426-
14271417
final store = PerAccountStoreWidget.of(context);
14281418
final url = store.tryResolveUrl(urlString);
14291419
if (url == null) { // TODO(log)
1430-
showError(context, null);
1420+
final zulipLocalizations = ZulipLocalizations.of(context);
1421+
showErrorDialog(context: context,
1422+
title: zulipLocalizations.errorCouldNotOpenLinkTitle,
1423+
message: zulipLocalizations.errorCouldNotOpenLink(urlString));
14311424
return;
14321425
}
14331426

@@ -1450,7 +1443,14 @@ void _launchUrl(BuildContext context, String urlString) async {
14501443
}
14511444
if (!launched) { // TODO(log)
14521445
if (!context.mounted) return;
1453-
showError(context, errorMessage);
1446+
1447+
final zulipLocalizations = ZulipLocalizations.of(context);
1448+
showErrorDialog(context: context,
1449+
title: zulipLocalizations.errorCouldNotOpenLinkTitle,
1450+
message: [
1451+
zulipLocalizations.errorCouldNotOpenLink(urlString),
1452+
if (errorMessage != null) errorMessage,
1453+
].join("\n\n"));
14541454
}
14551455
}
14561456

0 commit comments

Comments
 (0)