Fix search page results
This commit is contained in:
parent
1a132bdaf4
commit
a1aa9c09dc
|
@ -62,7 +62,8 @@ import { getConfig, getUserDefaultBool } from "../../utilities/settings";
|
|||
import {
|
||||
isDesktopApp,
|
||||
isDarwinApp,
|
||||
getElectronApp
|
||||
getElectronApp,
|
||||
linkablePath
|
||||
} from "../../utilities/desktop";
|
||||
import { Config } from "../../types/Config";
|
||||
import {
|
||||
|
@ -326,9 +327,10 @@ export class AppLayout extends Component<any, IAppLayoutState> {
|
|||
searchForQuery(what: string) {
|
||||
what = what.replace(/^#/g, "tag:");
|
||||
// console.log(what);
|
||||
window.location.href = isDesktopApp()
|
||||
? "hyperspace://hyperspace/app/index.html#/search?query=" + what
|
||||
: "/#/search?query=" + what;
|
||||
window.location.href = linkablePath("/#/search?query=" + what);
|
||||
// window.location.href = isDesktopApp()
|
||||
// ? "hyperspace://hyperspace/app/index.html#/search?query=" + what
|
||||
// : "/#/search?query=" + what;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,35 +84,23 @@ class SearchPage extends Component<any, ISearchPageState> {
|
|||
}
|
||||
}
|
||||
|
||||
runQueryCheck(newLocation?: string): ParsedQuery {
|
||||
let searchParams = "";
|
||||
if (newLocation !== undefined && typeof newLocation === "string") {
|
||||
searchParams = newLocation.replace("#/search", "");
|
||||
} else {
|
||||
searchParams = this.props.location.hash.replace("#/search", "");
|
||||
}
|
||||
return parseParams(searchParams);
|
||||
}
|
||||
|
||||
getQueryAndType(props: any) {
|
||||
let newSearch = this.runQueryCheck(props.location);
|
||||
let query: string | string[];
|
||||
const { search }: { search: string } = props.location;
|
||||
let newSearch = parseParams(search);
|
||||
let query: string | string[] = "";
|
||||
let type;
|
||||
|
||||
if (newSearch.query) {
|
||||
if (newSearch.query.toString().startsWith("tag:")) {
|
||||
if (search.includes("tag:")) {
|
||||
type = "tag";
|
||||
query = newSearch.query.toString().replace("tag:", "");
|
||||
} else {
|
||||
query = newSearch.query;
|
||||
}
|
||||
} else {
|
||||
query = "";
|
||||
query = newSearch.query.toString().replace("tag:", "");
|
||||
}
|
||||
|
||||
if (newSearch.type && newSearch.type !== undefined) {
|
||||
type = newSearch.type;
|
||||
}
|
||||
|
||||
return {
|
||||
query: query,
|
||||
type: type
|
||||
|
@ -155,14 +143,11 @@ class SearchPage extends Component<any, ISearchPageState> {
|
|||
let tagResults: [Status] = resp.data;
|
||||
this.setState({
|
||||
tagResults,
|
||||
viewDidLoad: true,
|
||||
viewIsLoading: false
|
||||
viewDidLoad: true
|
||||
});
|
||||
// console.log(this.state.tagResults);
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
this.setState({
|
||||
viewIsLoading: false,
|
||||
viewDidError: true,
|
||||
viewDidErrorCode: err.message
|
||||
});
|
||||
|
@ -171,6 +156,9 @@ class SearchPage extends Component<any, ISearchPageState> {
|
|||
`Couldn't search for posts with tag ${this.state.query}: ${err.name}`,
|
||||
{ variant: "error" }
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
this.setState({ viewIsLoading: false });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue