@@ -57,15 +57,19 @@ export interface IParseResponseDataWithCount<T = any> {
5757/**
5858 * @summary For things other than books, which should use `useBookQuery()`
5959 * @param T The type of the result record returned by Parse. Or use "any" or omit to ignore types.
60+ * If doNotActuallyRunQuery is true, the query will not be executed, and the result will always be empty.
61+ * (This is useful when rules of hooks force us to call this unconditionally, but we sometimes don't want to.)
6062 */
6163function useLibraryQuery < T = any > (
6264 queryClass : string ,
63- params : { }
65+ params : { } ,
66+ doNotActuallyRunQuery ?: boolean
6467) : IReturns < IParseResponseData < T > > {
6568 return useAxios < IParseResponseData < T > > ( {
6669 url : `${ getConnection ( ) . url } classes/${ queryClass } ` ,
6770 method : "GET" ,
6871 trigger : "true" ,
72+ forceDispatchEffect : ( ) => ! doNotActuallyRunQuery ,
6973 options : {
7074 headers : getConnection ( ) . headers ,
7175 params,
@@ -78,11 +82,14 @@ function useLibraryQuery<T = any>(
7882 */
7983function useLibraryQueryWithCount < T = any > (
8084 queryClass : string ,
81- params : { }
85+ params : { } ,
86+ doNotActuallyRunQuery ?: boolean
8287) : IReturns < IParseResponseDataWithCount < T > > {
83- return useLibraryQuery ( queryClass , { ...params , count : 1 } ) as IReturns <
84- IParseResponseDataWithCount < T >
85- > ;
88+ return useLibraryQuery (
89+ queryClass ,
90+ { ...params , count : 1 } ,
91+ doNotActuallyRunQuery
92+ ) as IReturns < IParseResponseDataWithCount < T > > ;
8693}
8794
8895function useGetLanguagesList ( ) {
@@ -103,10 +110,20 @@ export function useGetCleanedAndOrderedLanguageList(): ILanguage[] {
103110 return [ ] ;
104111}
105112export function useGetTagList ( ) : string [ ] {
106- const axiosResult = useLibraryQueryWithCount ( "tag" , {
107- limit : Number . MAX_SAFE_INTEGER ,
108- order : "name" ,
109- } ) ;
113+ // I'd prefer to use useAppHosted but it crashes, I think because this code runs outside the
114+ // scope where it works.
115+ const appHosted = isAppHosted ( ) ;
116+ const axiosResult = useLibraryQueryWithCount (
117+ "tag" ,
118+ {
119+ limit : Number . MAX_SAFE_INTEGER ,
120+ order : "name" ,
121+ } ,
122+ appHosted // don't actually run the query if we're app hosted; we don't need tags
123+ ) ;
124+ if ( appHosted ) {
125+ return [ "dummy" ] ; // don't need the list, but need non-empty to stop waiting.
126+ }
110127
111128 if ( axiosResult . response ?. data ?. results ) {
112129 assertAllParseRecordsReturned ( axiosResult . response ) ;
0 commit comments