Skip to content

Commit

Permalink
fix(admin-ui): Fix update of Channel when removing default currency/lang
Browse files Browse the repository at this point in the history
Fixes #2825
  • Loading branch information
michaelbromley committed Jun 3, 2024
1 parent 96f0410 commit 1e0c96f
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import { DEFAULT_CHANNEL_CODE } from '@vendure/common/lib/shared-constants';
import { gql } from 'apollo-angular';
import { Observable } from 'rxjs';
import { map, mergeMap, take } from 'rxjs/operators';
import { map, mergeMap, take, takeUntil } from 'rxjs/operators';

export const GET_CHANNEL_DETAIL = gql`
query GetChannelDetail($id: ID!) {
Expand Down Expand Up @@ -74,10 +74,29 @@ export class ChannelDetailComponent

ngOnInit() {
this.init();
// this.zones$ = this.dataService.settings.getZones({ take: 100 }).mapSingle(data => data.zones.items);
// TODO: make this lazy-loaded autocomplete
this.sellers$ = this.dataService.settings.getSellerList().mapSingle(data => data.sellers.items);
this.availableLanguageCodes$ = this.serverConfigService.getAvailableLanguages();
this.detailForm.controls.availableCurrencyCodes.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(value => {
if (value) {
const defaultCurrencyCode = this.detailForm.controls.defaultCurrencyCode.value;
if (defaultCurrencyCode && !value.includes(defaultCurrencyCode)) {
this.detailForm.controls.defaultCurrencyCode.setValue(value[0] as CurrencyCode);
}
}
});
this.detailForm.controls.availableLanguageCodes.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(value => {
if (value) {
const defaultLanguageCode = this.detailForm.controls.defaultLanguageCode.value;
if (defaultLanguageCode && !value.includes(defaultLanguageCode)) {
this.detailForm.controls.defaultLanguageCode.setValue(value[0] as LanguageCode);
}
}
});
}

ngOnDestroy() {
Expand Down

0 comments on commit 1e0c96f

Please sign in to comment.