Add support for showing Poll Widgets.#3554
Add support for showing Poll Widgets.#3554ishammahajan wants to merge 3 commits intozulip:masterfrom
Conversation
e0629ce to
e29641b
Compare
|
Thanks @ishammahajan! I just played with this a bit in the app, and with a different user in the webapp, on the same poll. Thoughts on the UI and functionality first -- mainly a number of style tweaks: ... you know what, I'll make this a thread on #mobile. That seems like the best venue for this part, because other people may have useful feedback too. |
|
Comments on the UX are here: Reading the code now. c174a0b user selectors: Add selector for retrieving current user.
509d8e0 widget poll: Add basic support to show widgets from available data.
When a condition will actually never happen, I'd rather not have code that only executes if it happens 🙂 . For one thing -- is returning One solution is a Here, I think a good solution is to listen to the type error as a signal that your interfaces don't match your logic -- you're in a condition where
be9d884 submessages: Add
|
2dfaedd to
4df00ed
Compare
|
(so I wrote this entire reply, and then it got erased because the browser closed, so the replies below will be terse in order to be efficient)
Thanks! I saw those commits initially, but was reluctant to reject
Makes sense. Fixed!
I agree, thanks! Fixed!
Sure, done!
My bad, I assumed that /**
* Option submessages are of type -
* {
* type: 'new_option',
* idx: number,
* option: string (Question String),
* }
*/
Sure! That would help out a lot.
Well, I tried to make it as template tagged as possible, but couldn't achieve it completely because we need to use a for loop to cover all the options anyways. Do you perhaps mean that there need to be functions which return perhaps a Map of option (
Is there any particular reason why you're recommending
Done! 😄 (I constructed some automation for rebasing PRs since code review usually involves a lot of rebasing and committing changed to a previous commit, which takes up a lot of time. That took a lot of time this round. Hopefully next round should be much swifter than normal -- noticed a saving of about 20-30 seconds in each of the last three changes I committed to this PR.) |
|
(the failure in CI doesn't seem to be related to this PR.) |
|
Thanks @ishammahajan for these revisions!
Ouch, yeah. That is a frustrating limitation in GitHub. 😢 The same thing happens to me sometimes and makes me tempted to write my comments in my own editor first... but never quite often enough to get me to pay the overhead of actually doing that. Hmm, reflecting on it, I think this is one of the reasons I've shifted to more often posting several separate comments if I have a lot to say. It limits just how much work I can lose if that happens.
Looks great, thanks! I think if I understand you right, the alternatives to About to merge that commit. I've also added a few new commits on top, mostly building on this in ways that came to mind when I was looking at it:
Next, I'll take a look at the rest of the branch. |
931df06fb widget poll: Add basic support to show widgets from available data.
... I have another remark to make, but I'll hit send at this point first 😅 |
931df06fb widget poll: Add basic support to show widgets from available data.(cont'd)
|
That's true! I'm pretty sure I understand it (at least enough that if I refer to this PR again, I will be able to solve further problems). Thanks!
That sounds good!
I'll fix that. Thanks!
Oh that makes it crystal clear!
Definitely! Thanks so much for the long explanation! 😄
Makes a lot more sense, fixing. :)
Which reminds me, I should probably do the same. |
4df00ed to
223678e
Compare
|
@gnprice Thanks for the review! :)
Ah, that makes so much more sense, again. It's fixed in my WD now.
Yeah, I don't remember why I thought that would even be a good idea now. |
Widgets support has been in great demand from users (as it was implemented in the webapp first, and we haven't supported its display since support was added to the API). You will also see a `Poll Widget` marker in the bottom right of the box which shows it. This commit adds the `poll` widget support, and modularises widgets so it will be easier to add other widgets if required. It uses the newly introduced (5046781) `getOwnUser` to get the `user_id` of the current user in order to check it against the `key` provided in submessages (which are only widgets for now) of type `vote`, to see if the current user has voted on the `option` in that `poll`. Styling has been duplicated from and merged with `.reaction`, while the borders of the `.widget` class has been changed to match the `.static-timestamp` class. Fixes zulip#3205.
Clicking on the button which shows the number of votes given to an option will now add a vote from your side to it, or remove the vote in case you had already voted on it. Implemented by adding `sendSubmessage.js` to the api index, which sends the vote request to the user's realm using an event handler in `webviewEventHanders.js`.
... like `.header` class is at the moment. Change the current application of the widget class to `dummy-widget` class. This is a pure refactor.
223678e to
44bb92e
Compare
|
Thanks @ishammahajan for the revisions -- this looks much nicer! 😄 d616773 widget poll: Add basic support to show widgets from available data.Just a few comments at this stage -- and none of them critical like the HTML injection was. 😉
I think a further improvement would be to fuse the two loops:
Quick thoughts outside of
eb62358 submessages: Add
|
|
(I just edited the PR description to add a cross-reference to the issue, #3205. That was already in one of the commits in the branch, which is important because the commits become our primary record of what we did... but because GitHub 🤷♂️ doesn't use that information as well as it could, it's separately important to mention any fixed issues in the PR description. In particular, this causes the issue thread to have a useful link back here to the PR.) |
I've written the key points here a few times ad hoc, including: #3496 (comment) #3554 (comment) (plus some useful Q&A in subsequent comments on the former), and others I don't have on hand. So, write it up a bit more fully in a place that's easy to find and to point people at. Also describe the `Fixes: #1234` syntax. We've often also said `Fixes #1234.`; but I've shifted to preferring the other form as we've started writing kernel-style `Frobbed-by:` lines, because it fits so naturally as one more of those.
|
(The issue is P1, so this is too.) |
|
What is the state on this pr? Can I help somehow? |


Widgets support has been in great demand from users (as it was
implemented in the webapp first, and we haven't supported its
display since support was added to the API).
This PR adds the
pollwidget support, and modularises widgetsso it will be easier to add other widgets if required. It uses the
newly introduced (c174a0)
getOwnUserto get theuser_idof thecurrent user in order to check it against the
keyprovided insubmessages (which are only widgets for now) of type
vote, to seeif the current user has voted on the
optionin thatpoll.Styling has been duplicated from and merged with
.reaction, whilethe borders of the
.widgetclass has been changed to match the.static-timestampclass. You will also see aPoll Widgetmarker in thebottom right of the box which shows it.
Fixes #3205 .