-
-
Notifications
You must be signed in to change notification settings - Fork 677
typing: Serialize recipients based on server version. #4022
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
Conversation
|
@gnprice @ray-kraesig please review. |
2f73ed1 to
8f14e5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't yet tested, but this looks reasonable. Some nits and notes follow.
(I assume you've tested against CZO or something close to it; but have you also tested it against any older Zulip server versions?)
71ee597 to
2566429
Compare
|
Thanks for the review, @ray-kraesig, I've pushed some changes. I tested this in CZO, and it worked -the app sends user ID arrays, and the typing notifications work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @agrawal-d, and @ray-kraesig for the review!
A few additional comments, mostly small.
src/users/usersActions.js
Outdated
| const activeAccount: Account | void = tryGetActiveAccount(state); | ||
| if (!activeAccount || activeAccount.zulipVersion === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the try... form -- if there's no active account then none of this can work anyway 🙂 and also it should be impossible to get to this function.
See the jsdoc:
/**
* The account currently foregrounded in the UI, or undefined if none.
*
* For use in early startup, onboarding, account-switch, or other times
* where there may be no active account.
*
* See `getActiveAccount` for use in the UI for an already-active account
* (including the bulk of the app), and code intended for that UI.
*/
export const tryGetActiveAccount = (state: GlobalState): Account | void => {
That also saves us from having to worry about whether this behavior is the right one in the case of no active account.
src/users/usersActions.js
Outdated
| let useEmailArrays: boolean; | ||
| const activeAccount: Account | void = tryGetActiveAccount(state); | ||
| if (!activeAccount || activeAccount.zulipVersion === undefined) { | ||
| useEmailArrays = false; | ||
| } else { | ||
| useEmailArrays = !new ZulipVersion(activeAccount.zulipVersion).isAtLeast( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can simplify some of this by having a const serverVersion = ... above, just getting the ZulipVersion | void that describes the server, before any of the logic specific to this API feature and the version threshold for it.
In particular then that can be factored out into a selector in accountsSelectors.js, like getServerVersion returning ZulipVersion | void.
src/users/usersActions.js
Outdated
| // User ID arrays are only supported in server versions >= 2.0.0-rc1, for | ||
| // versions before this, email arrays are used. If current server version is | ||
| // undetermined, user ID arrays are optimistically used. | ||
| // Support for user ID arrays was added in zulip/zulip commit 2f634f8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use 9 hex digits for a commit ID (git config --global core.abbrev 9 helps make this easy.)
For discussion see https://github.com/zulip/zulip-mobile/blob/master/docs/style.md#mentioning-commits , which I just wrote 😛 to explain why I've done this, and recommended it, for a long time.
src/users/usersActions.js
Outdated
| // User ID arrays are only supported in server versions >= 2.0.0-rc1, for | ||
| // versions before this, email arrays are used. If current server version is | ||
| // undetermined, user ID arrays are optimistically used. | ||
| // Support for user ID arrays was added in zulip/zulip commit 2f634f8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mention the commit ID right next to the version number -- they're two ways of describing the same fact
|
The only thing I'll add here is – ... ha! I literally got the notification for this commit as I was typing this sentence. As Greg notes, at least 9 hex digits, both in the commit message and in source comments. (In the commit message, for cross-repository commit references, you can use something along the lines of I don't actually recommend the Other than that, LGTM.
I recently attempted to do the same and failed. I'm not having internet connectivity issues, as far as I can tell; I fear that whatever cloud-side resources 1.9.x depended on may have vanished. I'll bring it up on CZO. I don't think this needs to block on that, though. Given that sending email arrays successfully reports typing presence in 2.2-dev, I feel safe in assuming that it'll work on previous versions. |
|
@gnprice @ray-kraesig thanks for the review. I've pushed some changes. Please take a look. |
|
You may notice that the GitHub UI still truncates the commit hash to 7 digits in the commit message, despite me having used the recommended 9 digits. |
Unfortunately, yes. The underlying commit message still has the correct number of digits in it, though, as can be seen by hovering on the link to your commit above. (I believe GitHub's linkifier also uses all provided digits, even if it doesn't present them.) My concerns are addressed, and it looks like Greg's have been, too – I'll give him some time to take a second look, but I'm looking forward to having this fix in. Thanks! |
'getServerVersion' returns the Zulip server version of the active account in the parsed form as a ZulipVersion instance, or undefined if we do not know the server version.
Zulip server versions >= 2.0.0-rc1 (zulip/zulip@2f634f8c0) require user ID arrays in the 'to' argument for the typing endpoint, whereas we currently send email arrays. Check the Zulip version and use the appropriate format of the argument, i.e., for versions >= 2.0.0-rc1 or when the Zulip server version is undetermined [1], use user ID arrays, otherwise, use email arrays. [1] The server started providing its version as early as zulip/zulip@d9b10727fa (released in 1.6.0, in 2017-06). It's more likely that we failed to parse a new, exotic version-string format than that someone's actually trying to connect to a Zulip server that doesn't provide one. Fixes zulip#3732.
Having just one place a variable gets its value helps simplify reading and thinking about the code.
|
Merged -- thanks again both! I added a couple of commits on top: one a code-style fixup, and one in part a jsdoc-style fixup and in part just adding some information to the jsdoc that we hadn't quite written down yet. I also slightly adjusted the commit messages' summary lines. |
Thanks, @gnprice! |
Zulip server versions >= 2.0.0-rc1 require user ID arrays in the
'to' argument for the typing endpoint, whereas we currently send
email arrays.
Check the Zulip version and use the appropriate format of the
argument, i.e., for versions >= 2.0.0-rc1 or when the Zulip server
version is undetermined, use user ID arrays, otherwise, use email
arrays.
Fixes #3732.