Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/task-editor/search.ts
1691 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { LocalViewStateMap } from "./types";
7
8
export function get_search(
9
local_view_state: LocalViewStateMap,
10
relevant_tags: { [tag: string]: true }
11
): string {
12
let search = "";
13
local_view_state
14
.get("selected_hashtags")
15
?.forEach(function (state: -1 | 1, tag: string): void {
16
if (!relevant_tags[tag]) {
17
return;
18
}
19
if (state === 1) {
20
search += " #" + tag + " ";
21
} else if (state === -1) {
22
search += " -#" + tag + " ";
23
}
24
});
25
return search + " " + (local_view_state.get("search") ?? "");
26
}
27
28