migrate UmbCurrentUserHistoryStore to UmbContextAlias
This commit is contained in:
@@ -7,7 +7,10 @@ import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '
|
||||
import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from './users/users/user.store';
|
||||
import { UmbUserGroupStore, UMB_USER_GROUP_STORE_CONTEXT_ALIAS } from './users/user-groups/user-group.store';
|
||||
import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './users/current-user/current-user.store';
|
||||
import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-history.store';
|
||||
import {
|
||||
UmbCurrentUserHistoryStore,
|
||||
UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS,
|
||||
} from './users/current-user/current-user-history.store';
|
||||
|
||||
import {
|
||||
UmbDocumentTypeStore,
|
||||
@@ -71,7 +74,7 @@ export class UmbBackofficeElement extends UmbLitElement {
|
||||
this.provideContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, new UmbUserGroupStore(this));
|
||||
this.provideContext(UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS, new UmbMemberGroupStore(this));
|
||||
this.provideContext(UMB_SECTION_STORE_CONTEXT_ALIAS, new UmbSectionStore());
|
||||
this.provideContext('umbCurrentUserHistoryStore', new UmbCurrentUserHistoryStore());
|
||||
this.provideContext(UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, new UmbCurrentUserHistoryStore());
|
||||
this.provideContext('umbDictionaryStore', new UmbDictionaryStore(this));
|
||||
this.provideContext('umbDocumentBlueprintStore', new UmbDocumentBlueprintStore(this));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { UmbContextAlias } from '@umbraco-cms/context-api';
|
||||
import { createObservablePart, UniqueBehaviorSubject } from '@umbraco-cms/observable-api';
|
||||
|
||||
export type UmbModelType = 'dialog' | 'sidebar';
|
||||
@@ -9,14 +10,10 @@ export type UmbCurrentUserHistoryItem = {
|
||||
};
|
||||
|
||||
export class UmbCurrentUserHistoryStore {
|
||||
|
||||
#history = new UniqueBehaviorSubject(
|
||||
<Array<UmbCurrentUserHistoryItem>>[]
|
||||
);
|
||||
#history = new UniqueBehaviorSubject(<Array<UmbCurrentUserHistoryItem>>[]);
|
||||
|
||||
public readonly history = this.#history.asObservable();
|
||||
public readonly latestHistory = createObservablePart(this.#history, historyItems => historyItems.slice(-10));
|
||||
|
||||
public readonly latestHistory = createObservablePart(this.#history, (historyItems) => historyItems.slice(-10));
|
||||
|
||||
constructor() {
|
||||
if (!('navigation' in window)) return;
|
||||
@@ -52,3 +49,7 @@ export class UmbCurrentUserHistoryStore {
|
||||
this.#history.next([]);
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS = new UmbContextAlias<UmbCurrentUserHistoryStore>(
|
||||
UmbCurrentUserHistoryStore.name
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { UserDetails } from '@umbraco-cms/models';
|
||||
import {
|
||||
UmbCurrentUserHistoryStore,
|
||||
UmbCurrentUserHistoryItem,
|
||||
UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS,
|
||||
} from 'src/backoffice/users/current-user/current-user-history.store';
|
||||
import {
|
||||
UmbCurrentUserStore,
|
||||
@@ -102,7 +103,7 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement {
|
||||
this._observeCurrentUser();
|
||||
});
|
||||
|
||||
this.consumeContext<UmbCurrentUserHistoryStore>('umbCurrentUserHistoryStore', (_instance) => {
|
||||
this.consumeContext(UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, (_instance) => {
|
||||
this._currentUserHistoryStore = _instance;
|
||||
this._observeHistory();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user