@@ -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
@@ -1869,6 +1870,24 @@ abstract class ComposeBoxState extends State<ComposeBox> {
1869
1870
1870
1871
/// Switch the compose box back to regular non-edit mode, with no content.
1871
1872
void endEditInteraction ();
1873
+
1874
+ /// Uploads the provided files, populating the content input with their links.
1875
+ ///
1876
+ /// If any of the file is larger than maximum file size allowed by the
1877
+ /// server, an error dialog is shown mentioning their names and actual
1878
+ /// file sizes.
1879
+ ///
1880
+ /// While uploading, a placeholder link is inserted in the content input and
1881
+ /// if [shouldRequestFocus] is true it will be focused. And then after
1882
+ /// uploading completes successfully the placeholder link will be replaced
1883
+ /// with an actual link.
1884
+ ///
1885
+ /// If there is an error while uploading a file, then an error dialog is
1886
+ /// shown mentioning the corresponding file name.
1887
+ Future <void > uploadFiles ({
1888
+ required Iterable <FileToUpload > files,
1889
+ required bool shouldRequestFocus,
1890
+ });
1872
1891
}
1873
1892
1874
1893
class _ComposeBoxState extends State <ComposeBox > with PerAccountStoreAwareStateMixin <ComposeBox > implements ComposeBoxState {
@@ -2021,6 +2040,19 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
2021
2040
});
2022
2041
}
2023
2042
2043
+ @override
2044
+ Future <void > uploadFiles ({
2045
+ required Iterable <FileToUpload > files,
2046
+ required bool shouldRequestFocus,
2047
+ }) async {
2048
+ await _uploadFiles (
2049
+ context: context,
2050
+ contentController: controller.content,
2051
+ contentFocusNode: controller.contentFocusNode,
2052
+ shouldRequestFocus: shouldRequestFocus,
2053
+ files: files);
2054
+ }
2055
+
2024
2056
@override
2025
2057
void onNewStore () {
2026
2058
final newStore = PerAccountStoreWidget .of (context);
0 commit comments