Skip to content

Commit

Permalink
Simplify, add default query
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach authored Oct 24, 2024
1 parent 559df5e commit e3b91df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions frontend/src/store/query/query.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
import { getQueryString } from "./query.selectors";
import { getQueryFromString } from "./utils";

const DEFAULT_QUERY = "sort:updated repo:developmentseed/now repo:developmentseed/how repo:developmentseed/ds-business repo:developmentseed/ds-team repo:developmentseed/operations repo:developmentseed/communications repo:developmentseed/ds-realwork repo:developmentseed/labs repo:developmentseed/ds-projectops repo:developmentseed/ds-devops repo:developmentseed/ds-metrics repo:developmentseed/ds-handbook repo:developmentseed/conferences-events";

const queryChanged = ([prevState, curState]: [RootState, RootState]) =>
JSON.stringify(prevState.query.query) !==
JSON.stringify(curState.query.query);
Expand Down Expand Up @@ -75,14 +77,8 @@ const loadFromUrl: RootEpic = (action$, state$, { config }) =>
getQueryFromString(
// Highly convoluted workflow to remove `code` & `state` from URL
new URLSearchParams(
Object.fromEntries(
Array.from(
new URLSearchParams(
state$.value.router.location.search
).entries()
).filter(([k, v]) => !["code", "state"].includes(k))
)
).toString()
state$.value.router.location.search
).get('q') || DEFAULT_QUERY
)
)
)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/store/query/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { QueryState } from "./query.reducer";

export const getQueryFromString = (url: string) =>
decodeURIComponent(url.slice(2))
.split("+")
url
.split(" ")
.map(v => v.split(":"))
.reduce(
(acc, v) => ({
Expand Down

0 comments on commit e3b91df

Please sign in to comment.