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: Calculate display_value from SearchPill item.

evykassirer7dfb92827748
diff --git a/web/src/search_pill.ts b/web/src/search_pill.ts
index 94149214726..18a880528e4 100644
--- a/web/src/search_pill.ts
+++ b/web/src/search_pill.ts
@@ -12,7 +12,6 @@ import type {User} from "./people";
import type {NarrowTerm} from "./state_data";
import * as user_status from "./user_status";
import type {UserStatusEmojiInfo} from "./user_status";
-import * as util from "./util";
export type SearchUserPill = {
type: "search_user";
@@ -64,7 +63,8 @@ export function create_item_from_search_string(search_string: string): SearchPil
}
export function get_search_string_from_item(item: SearchPill): string {
- return item.display_value;
+ const sign = item.negated ? "-" : "";
+ return `${sign}${item.operator}: ${get_search_operand(item)}`;
}
export function create_pills($pill_container: JQuery): SearchPillWidget {
@@ -78,20 +78,10 @@ export function create_pills($pill_container: JQuery): SearchPillWidget {
if (item.type === "search_user") {
return render_search_user_pill(item);
}
- // For search pills, we don't need to use + instead
- // of spaces in the pill, since there is visual separation
- // of pills. We also chose to add a space after the colon
- // after the search operator.
- // TODO: Ideally we wouldn't store a display value in a
- // non-display format, but we currently use `display_value`
- // not only for visual representation but also for parsing
- // the value a pill represents.
- // In the future we should change all input pills to have
- // a `value` as well as a `display_value`.
- let display_value = item.display_value.replaceAll("+", " ");
- display_value = display_value.replace(":", ": ");
- display_value = util.robust_url_decode(display_value).trim();
- return render_input_pill({display_value});
+ const display_value = get_search_string_from_item(item);
+ return render_input_pill({
+ display_value,
+ });
},
});
// We don't automatically create pills on paste. When the user