@@ -929,6 +929,7 @@ Future<void> _uploadFiles({
929
929
required BuildContext context,
930
930
required ComposeContentController contentController,
931
931
required FocusNode contentFocusNode,
932
+ bool shouldRequestFocus = true ,
932
933
required Iterable <FileToUpload > files,
933
934
}) async {
934
935
assert (context.mounted);
@@ -965,7 +966,7 @@ Future<void> _uploadFiles({
965
966
zulipLocalizations);
966
967
uploadsInProgress.add ((tag, file));
967
968
}
968
- if (! contentFocusNode.hasFocus) {
969
+ if (shouldRequestFocus && ! contentFocusNode.hasFocus) {
969
970
contentFocusNode.requestFocus ();
970
971
}
971
972
@@ -1550,6 +1551,32 @@ sealed class ComposeBoxController {
1550
1551
contentFocusNode.requestFocus ();
1551
1552
}
1552
1553
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
+
1553
1580
@mustCallSuper
1554
1581
void dispose () {
1555
1582
content.dispose ();
0 commit comments