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

reactions: Convert module to typescript #28375

Merged
merged 3 commits into from
Mar 5, 2024

Conversation

evykassirer
Copy link
Collaborator

@evykassirer evykassirer commented Dec 29, 2023

Split this into several commits since there was a lot going on.

reactions: Calculate vote_text before creating clean reaction. commit feels a bit messy but wasn't sure if there was a nicer way to do that. Would love feedback there

web/src/reactions.ts Outdated Show resolved Hide resolved
@evykassirer evykassirer added the area: typescript migration Issues for migrating Zulip to TypeScript label Dec 29, 2023
@andersk
Copy link
Member

andersk commented Jan 5, 2024

Okay looking at this more closely, it seems to me that emoji_code really is always a string, and the string | number put in emoji.ts by #24875 is just wrong, modulo a handful of Node test cases that are also wrong.

It’s converted here:

if realm_emoji is not None:
emoji_code = str(realm_emoji["id"])
return EmojiData(emoji_code=emoji_code, reaction_type=Reaction.REALM_EMOJI)

emoji_dict: EmojiInfo = dict(
id=str(realm_emoji.id),
name=realm_emoji.name,
source_url=emoji_url,
deactivated=realm_emoji.deactivated,
author_id=author_id,
still_url=None,
)

# Now update emoji_code to the new id.
row["emoji_code"] = str(new_realm_emoji_id)

evykassirer added a commit to evykassirer/zulip that referenced this pull request Jan 5, 2024
web/src/emoji.ts Outdated Show resolved Hide resolved
@evykassirer evykassirer marked this pull request as ready for review January 5, 2024 06:39
evykassirer added a commit to evykassirer/zulip that referenced this pull request Jan 5, 2024
evykassirer added a commit to evykassirer/zulip that referenced this pull request Jan 11, 2024
@timabbott
Copy link
Sponsor Member

I haven't tried to analyze, but I want to be very cautious about changes in when we do set_clean_reactions -- we had a whole set of bugs around unanticipated consequences of changing which resulted in my needing to do the refactoring ending in #28521 (comment).

If I recall correctly, the short of the issues there were things like that the previous code could do quadratic work (by computing the vote text summing up everyone's reactions for each reaction in the main loop over the reactions in a given message). Can you familiarize yourself with that and comment on the safety of these changes? It might be fine now, but I just want to make sure we're being careful here.

@evykassirer
Copy link
Collaborator Author

@timabbott the PR you're linking to seems like it's only backend changes, and I'm having trouble seeing how it's related. Did you link to the wrong thing maybe?

@evykassirer
Copy link
Collaborator Author

Pulled the less caution-needing prep commits to #28734

@evykassirer
Copy link
Collaborator Author

I haven't seen what the issue was before yet, so I might be missing something, but I added some comments about why I don't think these changes make things quadratic. Let me know if you want further clarification/explanation!

@evykassirer
Copy link
Collaborator Author

@timabbott / @andersk ready for you to take a look :)

@evykassirer
Copy link
Collaborator Author

@timabbott just making sure you saw this was ready

mananbordia pushed a commit to mananbordia/zulip that referenced this pull request Feb 27, 2024
When we move to typescript, we want to be able to calculate
this value *before* creating the clean reactions, so that
we can generate the clean reactions in one go instead of
having some half-created object.
This is essential for converting to typescript, because
we can't create half a clean reaction and then calculate
vote_text afterwards. Instead, we should calculate it
with the information we already have, and create the
clean reaction object afterwards, all at once.
@timabbott
Copy link
Sponsor Member

timabbott commented Mar 5, 2024

This looks like a correct conversion, so I think this is good to merge; going to do that without asking for revisions for the above, because it was a slog to read through and none of the issues above have functional impact. But I would appreciate a follow-up PR this week addressing them.

Thanks @evykassirer! This definitely wasn't an easy one.

@timabbott timabbott enabled auto-merge (rebase) March 5, 2024 02:47
@timabbott timabbott merged commit fb7d775 into zulip:main Mar 5, 2024
9 checks passed
@evykassirer evykassirer deleted the reactions-typescript branch March 5, 2024 18:04
Copy link
Collaborator Author

@evykassirer evykassirer left a comment

Choose a reason for hiding this comment

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

Made a followup PR: #29199

web/src/reactions.js Show resolved Hide resolved
web/src/reactions.ts Show resolved Hide resolved
web/src/reactions.ts Show resolved Hide resolved
web/src/reactions.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: typescript migration Issues for migrating Zulip to TypeScript size: XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants