File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
packages/skin-museum-client/src Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1+ import * as Utils from "./utils" ;
12import algoliasearch from "algoliasearch" ;
23var client = algoliasearch ( "HQ9I5Z6IM5" , "6466695ec3f624a5fccf46ec49680e51" ) ;
34
45var index = client . initIndex ( "Skins" ) ;
56
7+ export async function graphqlSearch ( query , options = { } ) {
8+ const queryText = Utils . gql `
9+ query SearchQuery($query: String!) {
10+ search_classic_skins(query: $query) {
11+ filename
12+ md5
13+ nsfw
14+ }
15+ }` ;
16+ const data = await Utils . fetchGraphql ( queryText , { query } ) ;
17+ const hits = data . search_classic_skins . map ( ( skin ) => {
18+ return {
19+ objectID : skin . md5 ,
20+ fileName : skin . filename ,
21+ nsfw : skin . nsfw ,
22+ } ;
23+ } ) ;
24+ return { hits } ;
25+ }
26+
627export function search ( query , options = { } ) {
728 return new Promise ( ( resolve , reject ) => {
829 index . search (
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import {
1919 takeWhile ,
2020 mergeAll ,
2121} from "rxjs/operators" ;
22- import { search } from "../algolia" ;
22+ import { search , graphqlSearch } from "../algolia" ;
2323import queryParser from "../queryParser" ;
2424import { CHUNK_SIZE } from "../constants" ;
2525import * as UploadUtils from "../upload/uploadUtils" ;
@@ -148,7 +148,7 @@ const searchEpic = (actions) =>
148148
149149 const [ newQuery , options ] = queryParser ( query ) ;
150150
151- return from ( search ( newQuery , options ) ) . pipe (
151+ return from ( graphqlSearch ( newQuery , options ) ) . pipe (
152152 map ( ( content ) => {
153153 const matchingSkins = content . hits . map ( ( hit ) => ( {
154154 hash : hit . objectID ,
You can’t perform that action at this time.
0 commit comments