Skip to content

Commit fb73e41

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 413bf1b commit fb73e41

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
@@ -1413,20 +1413,13 @@ class MessageTableCell extends StatelessWidget {
14131413
}
14141414

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

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

0 commit comments

Comments
 (0)