Skip to content

Commit

Permalink
fix(admin-ui): Fix theme & ui language switcher
Browse files Browse the repository at this point in the history
Fixes #3111. The recent changes in the data layer introduced this
regression. The solution is to internally use a ReplaySubject inside
the QueryResult class so that the initial values of any queryRef
are always available, even when subscribed _after_ the first
value was emitted.
  • Loading branch information
michaelbromley committed Oct 14, 2024
1 parent adb4384 commit c93589b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/admin-ui/src/lib/core/src/data/query-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
import { Apollo, QueryRef } from 'apollo-angular';
import { DocumentNode } from 'graphql';
import { merge, Observable, Subject, Subscription } from 'rxjs';
import { distinctUntilChanged, filter, finalize, map, skip, take, takeUntil } from 'rxjs/operators';
import {
distinctUntilChanged,
filter,
finalize,
map,
shareReplay,
skip,
startWith,
take,
takeUntil,
} from 'rxjs/operators';

import { CustomFieldConfig, GetUserStatusQuery } from '../common/generated-types';

Expand Down Expand Up @@ -194,7 +204,9 @@ export class QueryResult<T, V extends Record<string, any> = Record<string, any>>
this.subscribeToQueryRef(this.queryRef);
this.queryRefSubscribed.set(this.queryRef, true);
}
this.valueChangeSubject.subscribe(subscriber);
this.valueChangeSubject
.pipe(startWith(this.queryRef.getCurrentResult()), shareReplay(1))
.subscribe(subscriber);
return () => {
this.queryRefSubscribed.delete(this.queryRef);
};
Expand Down

0 comments on commit c93589b

Please sign in to comment.