Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
search_suggestion: Match query with description using lookup table.
Pratik Chandaa09572de3868
diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.tsindex b6f2a7a4061..f9a56926194 100644--- a/web/src/search_suggestion.ts+++ b/web/src/search_suggestion.ts@@ -42,6 +42,27 @@ const channel_incompatible_patterns: TermPattern[] = [{operator: "channels"},];+// TODO: Expand this to support all available filters and its description+// when we move away from description_html and calculate description on the+// fly by directly looking into this. We can ultimately support i18n too.+// Note: This list only contains search_strings used in `get_special_filters_suggestion`+// since only their corresponding descriptions are matched with search query.+const descriptions: Record<string, string> = {+ "is:resolved": "resolved topics",+ "-is:resolved": "unresolved topics",+ "is:dm": "direct messages",+ "is:starred": "starred messages",+ "is:mentioned": "messages that mention you",+ "is:followed": "followed topics",+ "is:alerted": "alerted messages",+ "is:unread": "unread messages",+ "is:muted": "muted messages",+ "has:link": "messages with links",+ "has:image": "messages with images",+ "has:attachment": "messages with attachments",+ "has:reaction": "messages with reactions",+};+const incompatible_patterns: Partial<Record<NarrowTerm["operator"], TermPattern[]>> &Record<| "is:resolved"@@ -715,7 +736,7 @@ function get_special_filter_suggestions(return (s.search_string.toLowerCase().startsWith(last_string) ||show_operator_suggestions ||- s.description_html?.toLowerCase().startsWith(last_string)+ descriptions[s.search_string]?.toLowerCase().startsWith(last_string));});const filtered_suggestions = suggestions.map(({incompatible_patterns, ...s}) => s);