Skip to content

compose: In topic or DM narrow, compose progress is lost when event queue expires #1470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrisbobbe opened this issue Apr 9, 2025 · 1 comment · Fixed by #1482
Closed
Assignees
Labels
a-compose Compose box, autocomplete, attaching files/images

Comments

@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Apr 9, 2025

To reproduce:

  1. Open a DM narrow or a topic narrow
  2. Type some text into the compose box
  3. Put the app in the background and wait at least 10 minutes
  4. Foreground the app; wait for new-queue loading indicator to disappear

Expected behavior: The text in the compose box is still there

Actual behavior: The text is cleared

In f1646c4, _ComposeBoxState started using PerAccountStoreAwareStateMixin. For DM and topic narrows, its onNewStore implementation drops the FixedDestinationComposeBoxController on the floor (without calling dispose) and makes a new one. It should only make a new one if it's the first time it's called.

Code:

  @override
  void onNewStore() {
    switch (widget.narrow) {
      case ChannelNarrow():
        final store = PerAccountStoreWidget.of(context);
        if (_controller == null) {
          _controller = StreamComposeBoxController(store: store);
        } else {
          (controller as StreamComposeBoxController).topic.store = store;
        }
      case TopicNarrow():
      case DmNarrow():
        _controller = FixedDestinationComposeBoxController();
      case CombinedFeedNarrow():
      case MentionsNarrow():
      case StarredMessagesNarrow():
        assert(false);
    }
  }

Possible fix (untested):

diff --git lib/widgets/compose_box.dart lib/widgets/compose_box.dart
index 966bec5f2..8d4b5fccc 100644
--- lib/widgets/compose_box.dart
+++ lib/widgets/compose_box.dart
@@ -1533,7 +1533,7 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
         }
       case TopicNarrow():
       case DmNarrow():
-        _controller = FixedDestinationComposeBoxController();
+        _controller ??= FixedDestinationComposeBoxController();
       case CombinedFeedNarrow():
       case MentionsNarrow():
       case StarredMessagesNarrow():

Assigning @PIG208 as the author of f1646c4.

@chrisbobbe chrisbobbe added the a-compose Compose box, autocomplete, attaching files/images label Apr 9, 2025
@chrisbobbe chrisbobbe added this to the M6: Post-launch milestone Apr 9, 2025
@chrisbobbe chrisbobbe assigned chrisbobbe and unassigned PIG208 Apr 17, 2025
@chrisbobbe
Copy link
Collaborator Author

chrisbobbe commented Apr 17, 2025

I'm refactoring this code on the way to #126, so I'll take this issue as part of that work. Edit: sent #1482

chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 24, 2025
And factor out a helper for the part that reads `widget.narrow` and
sets a new controller accordingly; we'll use this helper for the
edit-message UI, to reset the compose box at the end of an
edit-message session.

Fixes: zulip#1470
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this issue Apr 24, 2025
And factor out a helper for the part that reads `widget.narrow` and
sets a new controller accordingly; we'll use this helper for the
edit-message UI, to reset the compose box at the end of an
edit-message session.

Fixes: zulip#1470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-compose Compose box, autocomplete, attaching files/images
Projects
Status: Done
2 participants