File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
user/user/repository/config Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
8
8
* The base class for a store that holds an object.
9
9
*/
10
10
export class UmbStoreObjectBase < T > extends UmbContextBase < never > implements UmbApi {
11
- protected _data : UmbObjectState < T > ;
11
+ protected _data : UmbObjectState < T | undefined > ;
12
12
13
13
constructor ( host : UmbControllerHost , storeAlias : string , initialData ?: T ) {
14
14
super ( host , storeAlias ) ;
15
- this . _data = new UmbObjectState ( initialData ?? ( { } as T ) ) ;
15
+ this . _data = new UmbObjectState ( initialData ) ;
16
16
}
17
17
18
18
/**
@@ -29,7 +29,7 @@ export class UmbStoreObjectBase<T> extends UmbContextBase<never> implements UmbA
29
29
* Returns the current state of the store
30
30
* @memberof UmbStoreObjectBase
31
31
*/
32
- getState ( ) : T {
32
+ getState ( ) : T | undefined {
33
33
return this . _data . getValue ( ) ;
34
34
}
35
35
@@ -47,7 +47,7 @@ export class UmbStoreObjectBase<T> extends UmbContextBase<never> implements UmbA
47
47
* @memberof UmbStoreObjectBase
48
48
*/
49
49
part < Part extends keyof T > ( key : Part ) : Observable < T [ Part ] > {
50
- return this . _data . asObservablePart ( ( data ) => data [ key ] ) ;
50
+ return this . _data . asObservablePart ( ( data ) => data ! [ key ] ) ;
51
51
}
52
52
53
53
/**
Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ export class UmbUserConfigRepository extends UmbRepositoryBase implements UmbApi
19
19
}
20
20
21
21
async #init( ) {
22
+ // Check if the store already has data
23
+ if ( this . #dataStore?. getState ( ) ) {
24
+ return ;
25
+ }
26
+
22
27
const { data } = await this . #dataSource. getUserConfig ( ) ;
23
28
24
29
if ( data ) {
You can’t perform that action at this time.
0 commit comments