@@ -929,6 +929,7 @@ Future<void> _uploadFiles({
929929 required BuildContext context,
930930 required ComposeContentController contentController,
931931 required FocusNode contentFocusNode,
932+ bool shouldRequestFocus = true ,
932933 required Iterable <FileToUpload > files,
933934}) async {
934935 assert (context.mounted);
@@ -965,7 +966,7 @@ Future<void> _uploadFiles({
965966 zulipLocalizations);
966967 uploadsInProgress.add ((tag, file));
967968 }
968- if (! contentFocusNode.hasFocus) {
969+ if (shouldRequestFocus && ! contentFocusNode.hasFocus) {
969970 contentFocusNode.requestFocus ();
970971 }
971972
@@ -1550,6 +1551,32 @@ sealed class ComposeBoxController {
15501551 contentFocusNode.requestFocus ();
15511552 }
15521553
1554+ /// Uploads the provided files, populating the content input with their links.
1555+ ///
1556+ /// If any of the files are larger than maximum file size allowed by the
1557+ /// server, an error dialog is shown mentioning their names and actual
1558+ /// file sizes.
1559+ ///
1560+ /// While uploading, a placeholder link is inserted in the content input and
1561+ /// if [shouldRequestFocus] is true it will be focused. And then after
1562+ /// uploading completes successfully the placeholder link will be replaced
1563+ /// with an actual link.
1564+ ///
1565+ /// If there is an error while uploading a file, then an error dialog is
1566+ /// shown mentioning the corresponding file name.
1567+ Future <void > uploadFiles ({
1568+ required BuildContext context,
1569+ required Iterable <FileToUpload > files,
1570+ required bool shouldRequestFocus,
1571+ }) async {
1572+ await _uploadFiles (
1573+ context: context,
1574+ contentController: content,
1575+ contentFocusNode: contentFocusNode,
1576+ shouldRequestFocus: shouldRequestFocus,
1577+ files: files);
1578+ }
1579+
15531580 @mustCallSuper
15541581 void dispose () {
15551582 content.dispose ();
0 commit comments