Feature/streamline backend requests (#297)
* Introduce "RequestManager"
* Use "RequestManager" - Simple replacements
- Get rid of all "util/client" imports
- replace old requests with new "RequestManager"
- remove "fetcher" from global SWR config
instead of using the SWR hooks by themselves, the "requestManager" is supposed to be used
* Use "RequestManager" - Do requests via SWR hooks
Use SWR hooks at places where it's easily usable
* Prevent trailing slashes in the "baseUrl"
This commit is contained in:
@@ -6,9 +6,9 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { useQuery } from 'util/client';
|
||||
import { getMetadataFrom } from 'util/metadata';
|
||||
import { Metadata, ISearchSettings } from 'typings';
|
||||
import requestManager from 'lib/RequestManager';
|
||||
|
||||
export const getDefaultSettings = (): ISearchSettings => ({
|
||||
ignoreFilters: false,
|
||||
@@ -24,7 +24,7 @@ export const useSearchSettings = (): {
|
||||
settings: ISearchSettings;
|
||||
loading: boolean;
|
||||
} => {
|
||||
const { data: meta, isLoading } = useQuery<Metadata>('/api/v1/meta');
|
||||
const { data: meta, isLoading } = requestManager.useGetGlobalMeta();
|
||||
const settings = getSearchSettingsWithDefaultValueFallback(meta);
|
||||
|
||||
return { metadata: meta, settings, loading: isLoading };
|
||||
|
||||
Reference in New Issue
Block a user