Merge pull request #214 from hyperspacedev/develop-1.1.3-fix-search

v1.1.3 - Fix search page results
This commit is contained in:
Marquis Kurt 2020-06-22 21:43:13 -04:00 committed by GitHub
commit f51e00f54a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 54 deletions

74
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "hyperspace", "name": "hyperspace",
"version": "1.1.2", "version": "1.1.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -3697,6 +3697,16 @@
"integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==",
"dev": true "dev": true
}, },
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"dev": true,
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bluebird": { "bluebird": {
"version": "3.7.2", "version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@ -6190,9 +6200,9 @@
} }
}, },
"electron": { "electron": {
"version": "9.0.4", "version": "9.0.5",
"resolved": "https://registry.npmjs.org/electron/-/electron-9.0.4.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-9.0.5.tgz",
"integrity": "sha512-QzkeZNAiNB7KxcdoQKSoaiVT/GQdB4Vt0/ZZOuU8tIKABAsni2I7ztiAbUzxcsnQsqEBSfChuPuDQ5A4VbbzPg==", "integrity": "sha512-bnL9H48LuQ250DML8xUscsKiuSu+xv5umXbpBXYJ0BfvYVmFfNbG3jCfhrsH7aP6UcQKVxOG1R/oQExd0EFneQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
@ -7872,6 +7882,13 @@
"schema-utils": "^2.5.0" "schema-utils": "^2.5.0"
} }
}, },
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true,
"optional": true
},
"filelist": { "filelist": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz",
@ -9975,7 +9992,11 @@
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"dev": true, "dev": true,
"optional": true "optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
} }
} }
}, },
@ -11305,8 +11326,7 @@
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"dev": true
}, },
"minipass": { "minipass": {
"version": "3.1.3", "version": "3.1.3",
@ -11410,24 +11430,17 @@
} }
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "^1.2.5"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
} }
}, },
"moment": { "moment": {
"version": "2.26.0", "version": "2.27.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz",
"integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==", "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==",
"dev": true "dev": true
}, },
"move-concurrently": { "move-concurrently": {
@ -11471,6 +11484,13 @@
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true "dev": true
}, },
"nan": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==",
"dev": true,
"optional": true
},
"nanomatch": { "nanomatch": {
"version": "1.2.13", "version": "1.2.13",
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
@ -17663,7 +17683,11 @@
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"dev": true, "dev": true,
"optional": true "optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
}, },
"glob-parent": { "glob-parent": {
"version": "3.1.0", "version": "3.1.0",
@ -18061,7 +18085,11 @@
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"dev": true, "dev": true,
"optional": true "optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
}, },
"get-caller-file": { "get-caller-file": {
"version": "1.0.3", "version": "1.0.3",

View File

@ -1,7 +1,7 @@
{ {
"name": "hyperspace", "name": "hyperspace",
"productName": "Hyperspace Desktop", "productName": "Hyperspace Desktop",
"version": "1.1.2", "version": "1.1.3",
"description": "A beautiful, fluffy client for the fediverse", "description": "A beautiful, fluffy client for the fediverse",
"author": "Marquis Kurt <hyperspacedev@marquiskurt.net>", "author": "Marquis Kurt <hyperspacedev@marquiskurt.net>",
"repository": "https://github.com/hyperspacedev/hyperspace.git", "repository": "https://github.com/hyperspacedev/hyperspace.git",
@ -19,14 +19,14 @@
"@types/react-router-dom": "^4.3.5", "@types/react-router-dom": "^4.3.5",
"@types/react-swipeable-views": "latest", "@types/react-swipeable-views": "latest",
"axios": "^0.19.2", "axios": "^0.19.2",
"electron": "^9.0.4", "electron": "^9.0.5",
"electron-builder": "^22.7.0", "electron-builder": "^22.7.0",
"emoji-mart": "^2.11.2", "emoji-mart": "^2.11.2",
"file-dialog": "^0.0.7", "file-dialog": "^0.0.7",
"material-ui-pickers": "^2.2.4", "material-ui-pickers": "^2.2.4",
"mdi-material-ui": "^5.27.0", "mdi-material-ui": "^5.27.0",
"megalodon": "^0.6.4", "megalodon": "^0.6.4",
"moment": "^2.26.0", "moment": "^2.27.0",
"notistack": "^0.5.1", "notistack": "^0.5.1",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"query-string": "^6.13.1", "query-string": "^6.13.1",

View File

@ -1,5 +1,5 @@
{ {
"version": "1.1.2", "version": "1.1.3",
"location": "https://hyperspaceapp.herokuapp.com", "location": "https://hyperspaceapp.herokuapp.com",
"branding": { "branding": {
"name": "Hyperspace", "name": "Hyperspace",

View File

@ -62,7 +62,8 @@ import { getConfig, getUserDefaultBool } from "../../utilities/settings";
import { import {
isDesktopApp, isDesktopApp,
isDarwinApp, isDarwinApp,
getElectronApp getElectronApp,
linkablePath
} from "../../utilities/desktop"; } from "../../utilities/desktop";
import { Config } from "../../types/Config"; import { Config } from "../../types/Config";
import { import {
@ -326,9 +327,10 @@ export class AppLayout extends Component<any, IAppLayoutState> {
searchForQuery(what: string) { searchForQuery(what: string) {
what = what.replace(/^#/g, "tag:"); what = what.replace(/^#/g, "tag:");
// console.log(what); // console.log(what);
window.location.href = isDesktopApp() window.location.href = linkablePath("/#/search?query=" + what);
? "hyperspace://hyperspace/app/index.html#/search?query=" + what // window.location.href = isDesktopApp()
: "/#/search?query=" + what; // ? "hyperspace://hyperspace/app/index.html#/search?query=" + what
// : "/#/search?query=" + what;
} }
/** /**

View File

@ -19,7 +19,7 @@ import PersonAddIcon from "@material-ui/icons/PersonAdd";
import { styles } from "./PageLayout.styles"; import { styles } from "./PageLayout.styles";
import { LinkableIconButton, LinkableAvatar } from "../interfaces/overrides"; import { LinkableIconButton, LinkableAvatar } from "../interfaces/overrides";
import Mastodon from "megalodon"; import Mastodon from "megalodon";
import { parse as parseParams, ParsedQuery } from "query-string"; import { parse as parseParams } from "query-string";
import { Results } from "../types/Search"; import { Results } from "../types/Search";
import { withSnackbar } from "notistack"; import { withSnackbar } from "notistack";
import Post from "../components/Post"; import Post from "../components/Post";
@ -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) { getQueryAndType(props: any) {
let newSearch = this.runQueryCheck(props.location); const { search }: { search: string } = props.location;
let query: string | string[]; let newSearch = parseParams(search);
let query: string | string[] = "";
let type; let type;
if (newSearch.query) { if (newSearch.query) {
if (newSearch.query.toString().startsWith("tag:")) { if (search.includes("tag:")) {
type = "tag"; type = "tag";
query = newSearch.query.toString().replace("tag:", "");
} else {
query = newSearch.query;
} }
} else { query = newSearch.query.toString().replace("tag:", "");
query = "";
} }
if (newSearch.type && newSearch.type !== undefined) { if (newSearch.type && newSearch.type !== undefined) {
type = newSearch.type; type = newSearch.type;
} }
return { return {
query: query, query: query,
type: type type: type
@ -155,14 +143,11 @@ class SearchPage extends Component<any, ISearchPageState> {
let tagResults: [Status] = resp.data; let tagResults: [Status] = resp.data;
this.setState({ this.setState({
tagResults, tagResults,
viewDidLoad: true, viewDidLoad: true
viewIsLoading: false
}); });
// console.log(this.state.tagResults);
}) })
.catch((err: Error) => { .catch((err: Error) => {
this.setState({ this.setState({
viewIsLoading: false,
viewDidError: true, viewDidError: true,
viewDidErrorCode: err.message 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}`, `Couldn't search for posts with tag ${this.state.query}: ${err.name}`,
{ variant: "error" } { variant: "error" }
); );
})
.finally(() => {
this.setState({ viewIsLoading: false });
}); });
} }