Scanner Logik Fix

This commit is contained in:
Lorenz Hilpert
2021-05-17 15:43:21 +02:00
parent 69c8f9fe8c
commit 9742a58792
4 changed files with 23 additions and 16 deletions

View File

@@ -59,6 +59,7 @@ export class ArticleDetailsStore extends ComponentStore<ArticleDetailsState> {
//#region Lesepunkte
readonly fetchingPromotionPoints$ = this.select((s) => s.fetchingPromotionPoints);
readonly promotionPoints$ = this.item$.pipe(
filter((item) => !!item?.id && !!item.catalogAvailability?.price?.value?.value),
tap(() => this.patchState({ fetchingPromotionPoints: true, fetchingPromotionPointsError: undefined })),
switchMap((item) =>
!!item

View File

@@ -57,6 +57,10 @@ export class ArticleSearchStore extends ComponentStore<ArticleSearchState> {
readonly selectSearchState$: Observable<'fetching' | 'empty' | ''> = this.select((s) => s.searchState);
readonly selectQuery$: Observable<{ query: string; history?: boolean }> = this.select((s) => s.query);
get query() {
return this.get((s) => s.query);
}
readonly selectRecentQueries$: Observable<{ input: string; filter: string; primaryFilter: string }[]> = this.select(
(s) => s.recentQueries
);

View File

@@ -97,11 +97,11 @@ export class ArticleSearchboxComponent implements OnInit, OnDestroy {
this.subscriptions.unsubscribe();
}
async startSearch() {
const isMobile = await this.environmentService.isMobile();
const query = await this.query$.pipe(delay(100), first()).toPromise();
startSearch() {
const isNative = this.nativeContainer.isUiWebview().isNative;
const query = this.articleSearchStore.query?.query ?? '';
if (isMobile && (query?.length ?? 0) === 0) {
if (isNative && (query?.length ?? 0) === 0) {
return this.scan();
} else {
this.articleSearchStore.search({ empty: true, scrollPosReset: true });
@@ -152,11 +152,8 @@ export class ArticleSearchboxComponent implements OnInit, OnDestroy {
this.cdr.markForCheck();
}
async updateQuery(query: string) {
const isHistoryCall = await this.isHistory$.pipe(first()).toPromise();
if (!isHistoryCall) {
this.articleSearchStore.setQuery({ query });
}
updateQuery(query: string) {
this.articleSearchStore.setQuery({ query });
}
async autocompleteTrigger(queryAutocomplete: string) {

View File

@@ -63,14 +63,19 @@ export class UiSearchboxInputDirective implements ControlValueAccessor {
}
setValue(value: string, { inputType }: { inputType?: 'input' | 'autocomplete' | 'init' }) {
this.value = value;
this.onChange(value);
this.onTouched();
if (this.value !== value) {
this.value = value;
if (inputType === 'input') {
this.inputChange.emit(value);
} else if (inputType === 'autocomplete') {
this.select.emit(value);
if (inputType !== 'init') {
this.onChange(value);
this.onTouched();
}
if (inputType === 'input') {
this.inputChange.emit(value);
} else if (inputType === 'autocomplete') {
this.select.emit(value);
}
}
}
}