@@ -765,54 +765,6 @@ class StarButton extends MessageActionSheetMenuItemButton {
765765 }
766766}
767767
768- /// Fetch and return the raw Markdown content for [messageId] ,
769- /// showing an error dialog on failure.
770- Future <String ?> fetchRawContentWithFeedback ({
771- required BuildContext context,
772- required int messageId,
773- required String errorDialogTitle,
774- }) async {
775- Message ? fetchedMessage;
776- String ? errorMessage;
777- // TODO, supported by reusable code:
778- // - (?) Retry with backoff on plausibly transient errors.
779- // - If request(s) take(s) a long time, show snackbar with cancel
780- // button, like "Still working on quote-and-reply…".
781- // On final failure or success, auto-dismiss the snackbar.
782- final zulipLocalizations = ZulipLocalizations .of (context);
783- try {
784- fetchedMessage = await getMessageCompat (PerAccountStoreWidget .of (context).connection,
785- messageId: messageId,
786- applyMarkdown: false ,
787- );
788- if (fetchedMessage == null ) {
789- errorMessage = zulipLocalizations.errorMessageDoesNotSeemToExist;
790- }
791- } catch (e) {
792- switch (e) {
793- case ZulipApiException ():
794- errorMessage = e.message;
795- // TODO specific messages for common errors, like network errors
796- // (support with reusable code)
797- default :
798- errorMessage = zulipLocalizations.errorCouldNotFetchMessageSource;
799- }
800- }
801-
802- if (! context.mounted) return null ;
803-
804- if (fetchedMessage == null ) {
805- assert (errorMessage != null );
806- // TODO(?) give no feedback on error conditions we expect to
807- // flag centrally in event polling, like invalid auth,
808- // user/realm deactivated. (Support with reusable code.)
809- showErrorDialog (context: context,
810- title: errorDialogTitle, message: errorMessage);
811- }
812-
813- return fetchedMessage? .content;
814- }
815-
816768class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
817769 QuoteAndReplyButton ({super .key, required super .message, required super .pageContext});
818770
@@ -849,7 +801,7 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
849801 message: message,
850802 );
851803
852- final rawContent = await fetchRawContentWithFeedback (
804+ final rawContent = await ZulipAction . fetchRawContentWithFeedback (
853805 context: pageContext,
854806 messageId: message.id,
855807 errorDialogTitle: zulipLocalizations.errorQuotationFailed,
@@ -901,12 +853,13 @@ class CopyMessageTextButton extends MessageActionSheetMenuItemButton {
901853
902854 @override void onPressed () async {
903855 // This action doesn't show request progress.
904- // But hopefully it won't take long at all; and
905- // fetchRawContentWithFeedback has a TODO for giving feedback if it does.
856+ // But hopefully it won't take long at all,
857+ // and [ZulipAction.fetchRawContentWithFeedback] has a TODO
858+ // for giving feedback if it does.
906859
907860 final zulipLocalizations = ZulipLocalizations .of (pageContext);
908861
909- final rawContent = await fetchRawContentWithFeedback (
862+ final rawContent = await ZulipAction . fetchRawContentWithFeedback (
910863 context: pageContext,
911864 messageId: message.id,
912865 errorDialogTitle: zulipLocalizations.errorCopyingFailed,
@@ -973,7 +926,7 @@ class ShareButton extends MessageActionSheetMenuItemButton {
973926
974927 final zulipLocalizations = ZulipLocalizations .of (pageContext);
975928
976- final rawContent = await fetchRawContentWithFeedback (
929+ final rawContent = await ZulipAction . fetchRawContentWithFeedback (
977930 context: pageContext,
978931 messageId: message.id,
979932 errorDialogTitle: zulipLocalizations.errorSharingFailed,
0 commit comments