composebox_typeahead: Refactor content_highlighter to use switch/case.

This refactor should make no functional changes.
This commit is contained in:
YashRE42 2020-10-18 05:22:34 +00:00 committed by Tim Abbott
parent f843c2285d
commit 13f95dfc2b
1 changed files with 23 additions and 19 deletions

View File

@ -716,26 +716,30 @@ exports.get_candidates = function (query) {
};
exports.content_highlighter = function (item) {
if (this.completing === "emoji") {
switch (this.completing) {
case "emoji":
return typeahead_helper.render_emoji(item);
} else if (this.completing === "mention" || this.completing === "silent_mention") {
case "mention":
return typeahead_helper.render_person_or_user_group(item);
} else if (this.completing === "slash") {
case "silent_mention":
return typeahead_helper.render_person_or_user_group(item);
case "slash":
return typeahead_helper.render_typeahead_item({
primary: item.text,
});
} else if (this.completing === "stream") {
case "stream":
return typeahead_helper.render_stream(item);
} else if (this.completing === "syntax") {
case "syntax":
return typeahead_helper.render_typeahead_item({primary: item});
} else if (this.completing === "topic_jump") {
case "topic_jump":
return typeahead_helper.render_typeahead_item({primary: item});
} else if (this.completing === "topic_list") {
case "topic_list":
return typeahead_helper.render_typeahead_item({primary: item});
} else if (this.completing === "time_jump") {
case "time_jump":
return typeahead_helper.render_typeahead_item({primary: item});
}
default:
return undefined;
}
};
const show_flatpickr = (element, callback, default_timestamp) => {