Skip to content

Commit

Permalink
Merge pull request #1774 from umbraco/bugfix/global-requests-retry
Browse files Browse the repository at this point in the history
Retry requests after log in
  • Loading branch information
iOvergaard authored May 7, 2024
2 parents 5335f03 + f6123d4 commit 5d11765
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/apps/backoffice/backoffice.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registr
import type { ManifestSection } from '@umbraco-cms/backoffice/extension-registry';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbExtensionManifestInitializer } from '@umbraco-cms/backoffice/extension-api';
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';

export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
#activeSectionAlias = new UmbStringState(undefined);
Expand All @@ -26,7 +27,13 @@ export class UmbBackofficeContext extends UmbContextBase<UmbBackofficeContext> {
this.#allowedSections.setValue([...sections]);
});

this.#getVersion();
// TODO: We need to ensure this request is called every time the user logs in, but this should be done somewhere across the app and not here [JOV]
this.consumeContext(UMB_AUTH_CONTEXT, (authContext) => {
this.observe(authContext.isAuthorized, (isAuthorized) => {
if (!isAuthorized) return;
this.#getVersion();
});
});
}

async #getVersion() {
Expand Down
11 changes: 10 additions & 1 deletion src/apps/backoffice/backoffice.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@umbraco-cms/backoffice/extension-registry';
import { UmbServerExtensionRegistrator } from '@umbraco-cms/backoffice/extension-api';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';

import './components/index.js';

Expand Down Expand Up @@ -58,7 +59,15 @@ export class UmbBackofficeElement extends UmbLitElement {
umbExtensionsRegistry.registerMany(packageModule.extensions);
});

new UmbServerExtensionRegistrator(this, umbExtensionsRegistry).registerPrivateExtensions();
const serverExtensions = new UmbServerExtensionRegistrator(this, umbExtensionsRegistry);

// TODO: We need to ensure this request is called every time the user logs in, but this should be done somewhere across the app and not here [JOV]
this.consumeContext(UMB_AUTH_CONTEXT, (authContext) => {
this.observe(authContext.isAuthorized, (isAuthorized) => {
if (!isAuthorized) return;
serverExtensions.registerPrivateExtensions();
});
});
}

render() {
Expand Down
10 changes: 9 additions & 1 deletion src/packages/language/global-contexts/app-language.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';

// TODO: Make a store for the App Languages.
// TODO: Implement default language end-point, in progress at backend team, so we can avoid getting all languages.
Expand All @@ -28,7 +29,14 @@ export class UmbAppLanguageContext extends UmbContextBase<UmbAppLanguageContext>
constructor(host: UmbControllerHost) {
super(host, UMB_APP_LANGUAGE_CONTEXT);
this.#languageCollectionRepository = new UmbLanguageCollectionRepository(this);
this.#observeLanguages();

// TODO: We need to ensure this request is called every time the user logs in, but this should be done somewhere across the app and not here [JOV]
this.consumeContext(UMB_AUTH_CONTEXT, (authContext) => {
this.observe(authContext.isAuthorized, (isAuthorized) => {
if (!isAuthorized) return;
this.#observeLanguages();
});
});
}

setLanguage(unique: string) {
Expand Down

0 comments on commit 5d11765

Please sign in to comment.