Skip to content

Conversation

MritunjayTiwari14
Copy link

Pull Request: [Circular Loading Indicator Implementation](polls: Add UI feedback on vote button while request pending #1808)

Hello Moderators of Zulip Flutter,
This is Mritunjay Tiwari.
This is my first ever contribution to Zulip.


📌 My Solution

Implementation Video and Images

record.mp4

I have researched for many days about the best practices to implement a Circular Loading Indicator.

At the end, I found that it is very hard and not efficient to implement a progress indicator for an unawaited process on which the pull request depends.

So, I came up with an efficient solution:
by converting the unawaited process to an awaited process, we can easily capture the loading state and then implement a circular loading indicator within the function itself.


Thank you for reviewing my contribution!

💻 Code Snippet

void _toggleVote(PollOption option) async {
    final navigator = Navigator.of(context);

    unawaited(showDialog(context: context,
        barrierDismissible: false,
        builder: (_) {
        return Center(child: CircularProgressIndicator());
      }
    ));

    final store = PerAccountStoreWidget.of(context);
    final op = option.voters.contains(store.selfUserId)
      ? PollVoteOp.remove
      : PollVoteOp.add;
    await(sendSubmessage(store.connection, messageId: widget.messageId,
      submessageType: SubmessageType.widget,
      content: PollVoteEventSubmessage(key: option.key, op: op)));

    navigator.pop();
  }

Copy link
Contributor

@apoorvapendse apoorvapendse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @MritunjayTiwari14,
Let's fix up the commit message by following the commit style guidelines.

Something like:

poll: Display UI feedback on poll delay.

<description>

Fixes: #1808

Might be a better way to write this.
Feel free to add details and helpful info in the commit description.

Copy link
Contributor

@apoorvapendse apoorvapendse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting a thread in the #mobile-design channel might be useful to gain initial feedback on this.

We replaced the unawaited call to sendSubmessage() with an awaited call.
This ensures that the operation's start and completion can be tracked, which makes it possible to implement a loading indicator. With the previous unawaited behavior, there was no reliable way to measure the duration of the process.

Fixes: zulip#1808
@MritunjayTiwari14
Copy link
Author

Thanks for the PR @MritunjayTiwari14, Let's fix up the commit message by following the commit style guidelines.

Something like:

poll: Display UI feedback on poll delay.

<description>

Fixes: #1808

Might be a better way to write this. Feel free to add details and helpful info in the commit description.

Thank you very much for Reviewing! @apoorvapendse
The commit description has been successfully Updated as per commit style guidelines.

@MritunjayTiwari14
Copy link
Author

Starting a thread in the #mobile-design channel might be useful to gain initial feedback on this.

Okay, I will look forward into this Channel for further feedback.

@apoorvapendse
Copy link
Contributor

Cool, let's line wrap the description to <= 70 characters per line.
See formatting guidelines.

@alya
Copy link
Collaborator

alya commented Sep 2, 2025

If we show a spinner, I'd expect it to appear on the poll, not blocking the user from reading their other messages.

@MritunjayTiwari14
Copy link
Author

Cool, let's line wrap the description to <= 70 characters per line. See formatting guidelines.

I will make sure to use line wrap in the Description from Now, thank you.

@MritunjayTiwari14
Copy link
Author

If we show a spinner, I'd expect it to appear on the poll, not blocking the user from reading their other messages.

Okay, I’ll work on implementing a spinner similar to the Zulip web poll system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants