Fix currentApiClient return type to include undefined
This commit is contained in:
parent
516bd2aab8
commit
5db9384c9c
5 changed files with 6 additions and 6 deletions
|
@ -128,8 +128,8 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
// If this is an admin route, ensure the user has access
|
// If this is an admin route, ensure the user has access
|
||||||
if (isAdminRequired) {
|
if (isAdminRequired) {
|
||||||
try {
|
try {
|
||||||
const user = await client.getCurrentUser();
|
const user = await client?.getCurrentUser();
|
||||||
if (!user.Policy?.IsAdministrator) {
|
if (!user?.Policy?.IsAdministrator) {
|
||||||
console.warn('[ConnectionRequired] normal user attempted to access admin route');
|
console.warn('[ConnectionRequired] normal user attempted to access admin route');
|
||||||
bounce(await ServerConnections.connect());
|
bounce(await ServerConnections.connect());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -88,7 +88,7 @@ class ServerConnections extends ConnectionManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ApiClient that is currently connected.
|
* Gets the ApiClient that is currently connected.
|
||||||
* @returns {ApiClient} apiClient
|
* @returns {ApiClient|undefined} apiClient
|
||||||
*/
|
*/
|
||||||
currentApiClient() {
|
currentApiClient() {
|
||||||
let apiClient = this.getLocalApiClient();
|
let apiClient = this.getLocalApiClient();
|
||||||
|
|
|
@ -34,7 +34,7 @@ const ServerContentPage: FunctionComponent<ServerContentPageProps> = ({ view })
|
||||||
const apiClient = ServerConnections.currentApiClient();
|
const apiClient = ServerConnections.currentApiClient();
|
||||||
|
|
||||||
// Fetch the view html from the server and translate it
|
// Fetch the view html from the server and translate it
|
||||||
const viewHtml = await apiClient.get(apiClient.getUrl(view + location.search))
|
const viewHtml = await apiClient?.get(apiClient.getUrl(view + location.search))
|
||||||
.then((html: string) => globalize.translateHtml(html));
|
.then((html: string) => globalize.translateHtml(html));
|
||||||
|
|
||||||
viewManager.loadView({
|
viewManager.loadView({
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const ApiProvider: FC = ({ children }) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ServerConnections.currentApiClient()
|
ServerConnections.currentApiClient()
|
||||||
.getCurrentUser()
|
?.getCurrentUser()
|
||||||
.then(newUser => updateApiUser(undefined, newUser))
|
.then(newUser => updateApiUser(undefined, newUser))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.info('[ApiProvider] Could not get current user', err);
|
console.info('[ApiProvider] Could not get current user', err);
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update active ApiClient.
|
* Update active ApiClient.
|
||||||
* @param {Object} apiClient The ApiClient.
|
* @param {ApiClient|undefined} apiClient The ApiClient.
|
||||||
*/
|
*/
|
||||||
updateApiClient(apiClient) {
|
updateApiClient(apiClient) {
|
||||||
if (!apiClient) {
|
if (!apiClient) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue