Skip to content
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

feat: update poll #3111

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Cl0v1s
Copy link
Contributor

@Cl0v1s Cl0v1s commented Dec 29, 2024

Add an "update poll" option on polls to retrieve the latest results

update poll option (french)

Upodate poll option on hover (french)

The refresh icon is animated during loading

Copy link

netlify bot commented Dec 29, 2024

Deploy Preview for elk-docs canceled.

Name Link
🔨 Latest commit 9c8c824
🔍 Latest deploy log https://app.netlify.com/sites/elk-docs/deploys/67727d13afe8d50008300e78

Copy link

netlify bot commented Dec 29, 2024

Deploy Preview for elk-zone ready!

Name Link
🔨 Latest commit 9c8c824
🔍 Latest deploy log https://app.netlify.com/sites/elk-zone/deploys/67727d139e555400085855f0
😎 Deploy Preview https://deploy-preview-3111--elk-zone.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@shuuji3 shuuji3 left a comment

Choose a reason for hiding this comment

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

Thanks, this is a nice addition.

I checked the change with this preview post: https://deploy-preview-3111--elk-zone.netlify.app/universeodon.com/@elkdev/112190894000305452

One comment: once the poll is finalized, it won't be updated anymore, so should we hide the update button after that?

@Cl0v1s
Copy link
Contributor Author

Cl0v1s commented Dec 31, 2024 via email

@shuuji3
Copy link
Member

shuuji3 commented Dec 31, 2024

I think hiding it would be better because

  1. When the poll has already finished, users won't see the update button so we can avoid making them think it can be updated and they might think there's some issue they cannot click it until they realize the poll was finished at that time.
  2. When the poll is still ongoing, users can click the update button to see the latest numbers until it finishes and can know it's finished clearly.

@Cl0v1s
Copy link
Contributor Author

Cl0v1s commented Jan 3, 2025

Will do !

@Cl0v1s
Copy link
Contributor Author

Cl0v1s commented Jan 3, 2025

On second though, there is still the following case: the poll is indeed closed but the local instance did not refetched the results yet (I saw that happening from time to time). Is this a case we should consider ?

@shuuji3
Copy link
Member

shuuji3 commented Jan 6, 2025

That sounds a bit tricky. So in my understanding, there are three phases about the poll state and returned poll data:

  1. The poll is still ongoing on remote server, and the local server returns the unfinished poll data.
  2. The poll was actually finished on remote server, but the local server returns the outdated poll data.
  3. The poll was finished and the local server returns the latest finished poll data.

Since Elk can only send request to the local server via masto.js, we can only see the local poll data (possibly outdated) and we can use either expired (boolean) and expiredAt (time to finish) props in Poll (ref. https://neet.github.io/masto.js/interfaces/mastodon.v1.Poll.html) to determine if the poll is finished.

So if we compared expiredAt with the current time and hide the update button, we shows the wrong state for case 2. In this case, Elk shows the poll was finished and hide the update button, but the poll count was not the latest and users cannot update the result anymore.

That means we need to use expired and hide the update button only if its value is true (after local server synced the latest poll data).

Do you think my assumption is correct?

@Cl0v1s
Copy link
Contributor Author

Cl0v1s commented Jan 6, 2025 via email

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.

2 participants