emoji: Restrict reaction_type for compatibility with typeahead.Emoji.

This commit is contained in:
evykassirer 2024-04-25 14:13:52 -07:00 committed by Tim Abbott
parent 297fd2654d
commit 7a9a445088
5 changed files with 8 additions and 8 deletions

View File

@ -66,7 +66,7 @@ type EmojiDict = {
// Details needed by template to render an emoji.
export type EmojiRenderingDetails = {
emoji_name: string;
reaction_type: string;
reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
emoji_code: string;
url?: string;
still_url?: string | null;
@ -325,7 +325,7 @@ export function get_emoji_details_by_name(emoji_name: string): EmojiRenderingDet
export function get_emoji_details_for_rendering(opts: {
emoji_name: string;
emoji_code: string;
reaction_type: string;
reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
}): EmojiRenderingDetails {
if (opts.reaction_type !== "unicode_emoji") {
const realm_emoji = all_realm_emojis.get(opts.emoji_code);

View File

@ -100,7 +100,7 @@ export type MessageCleanReaction = {
is_realm_emoji: boolean;
label: string;
local_id: string;
reaction_type: string;
reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
user_ids: number[];
vote_text: string;
};

View File

@ -24,7 +24,7 @@ type ReactionEvent = {
message_id: number;
user_id: number;
local_id: string;
reaction_type: string;
reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
emoji_name: string;
emoji_code: string;
};
@ -53,7 +53,7 @@ function get_message(message_id: number): Message | undefined {
export type RawReaction = {
emoji_name: string;
reaction_type: string;
reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
emoji_code: string;
user_id: number;
};
@ -566,7 +566,7 @@ function make_clean_reaction({
user_ids: number[];
emoji_name: string;
emoji_code: string;
reaction_type: string;
reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
should_display_reactors: boolean;
}): MessageCleanReaction {
const emoji_details = emoji.get_emoji_details_for_rendering({

View File

@ -19,7 +19,7 @@ const user_status_schema = z.intersection(
z.object({
emoji_name: z.string(),
emoji_code: z.string(),
reaction_type: z.string(),
reaction_type: z.enum(["zulip_extra_emoji", "realm_emoji", "unicode_emoji"]),
}),
z.object({
emoji_name: z.undefined(),

View File

@ -119,7 +119,7 @@ run_test("basics", () => {
type: "user_status",
emoji_name: "",
emoji_code: "",
reaction_type: "",
reaction_type: "unicode_emoji",
status_text: "",
});
assert.deepEqual(user_status.get_status_emoji(2), undefined);