Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

search_pill: Relax type requirement to set search bar terms.

Aman Agrawal58a17e3b955e
diff --git a/web/src/search_pill.ts b/web/src/search_pill.ts
index 7e510e680cf..563ce7bf4b6 100644
--- a/web/src/search_pill.ts
+++ b/web/src/search_pill.ts
@@ -12,7 +12,7 @@ import type {InputPill, InputPillContainer} from "./input_pill.ts";
import * as people from "./people.ts";
import type {User} from "./people.ts";
import {type Suggestion, search_term_description_html} from "./search_suggestion.ts";
-import type {NarrowTerm} from "./state_data.ts";
+import type {NarrowTerm, NarrowTermSuggestion} from "./state_data.ts";
import * as state_data from "./state_data.ts";
import * as stream_data from "./stream_data.ts";
import * as user_status from "./user_status.ts";
@@ -297,7 +297,7 @@ function append_user_pill(
}
export function set_search_bar_contents(
- search_terms: NarrowTerm[],
+ search_terms: NarrowTermSuggestion[],
pill_widget: SearchPillWidget,
is_typeahead_visible: boolean,
set_search_bar_text: (text: string) => void,
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index 7079814e677..41369783c19 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -20,6 +20,14 @@ const group_permission_setting_schema = z.object({
});
export type GroupPermissionSetting = z.output<typeof group_permission_setting_schema>;
+// We cannot parse the operand since it is incomplete,
+// only used for generating suggestions.
+export type NarrowTermSuggestion = {
+ operator: NarrowTerm["operator"];
+ operand: string;
+ negated?: boolean | undefined;
+};
+
export const narrow_canonical_operator_schema = z.enum([
"", // Used for search suggestions.
"channel",