
Try to get the `.editorconfig` and `.prettierrc` files as close as possible to the formatting that was used in Flamenco. Because these files weren't here during most of Flamenco's development so far, having them caused quite a few changes in the webapp files. No functional changes intended.
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { ApiClient } from '@/manager-api';
|
|
import { CountingApiClient } from '@/stores/api-query-count';
|
|
import { api as apiURL } from '@/urls';
|
|
|
|
/**
|
|
* Scrub the custom User-Agent header from the API client, for those webbrowsers
|
|
* who do not want to have it set.
|
|
*
|
|
* It's actually scrubbed for all webbrowsers, as those privacy-first
|
|
* webbrowsers also make it hard to fingerprint which browser you're using (for
|
|
* good reason).
|
|
*
|
|
* @param {ApiClient} apiClient
|
|
*/
|
|
export function scrubAPIClient(apiClient) {
|
|
delete apiClient.defaultHeaders['User-Agent'];
|
|
}
|
|
|
|
/**
|
|
* @returns {ApiClient} Bare API client that is not connected to the UI in any way.
|
|
*/
|
|
export function newBareAPIClient() {
|
|
const apiClient = new ApiClient(apiURL());
|
|
scrubAPIClient(apiClient);
|
|
return apiClient;
|
|
}
|
|
|
|
let apiClient = null;
|
|
|
|
/**
|
|
* @returns {ApiClient} API client that updates the UI to show long-running queries.
|
|
*/
|
|
export function getAPIClient() {
|
|
if (apiClient == null) {
|
|
apiClient = new CountingApiClient(apiURL());
|
|
scrubAPIClient(apiClient);
|
|
}
|
|
return apiClient;
|
|
}
|