fix: run prettier on all file to avoid prettier issue inside PR

This commit is contained in:
thomas
2024-01-07 21:41:36 +01:00
parent 3bc793f6b3
commit c8b7c5d4a6
195 changed files with 575 additions and 452 deletions

View File

@@ -6,7 +6,10 @@ import { Directive, DoCheck, ElementRef, NgZone } from '@angular/core';
standalone: true,
})
export class CDFlashingDirective implements DoCheck {
constructor(private elementRef: ElementRef, private zone: NgZone) {}
constructor(
private elementRef: ElementRef,
private zone: NgZone,
) {}
ngDoCheck(): void {
this.cdRan();

View File

@@ -175,8 +175,7 @@ export class CallStateError {
export class CallStateErrorHandler implements ErrorHandler<CallStateError> {
toError = (error: unknown): CallStateError => {
if (error instanceof CallStateError) return error;
if (error instanceof Error)
return new CallStateError(error.name, error.message);
if (error instanceof Error) return new CallStateError(error.name, error.message);
return new CallStateError(UNKNOWN_ERROR_CAUSE, UNKNOWN_ERROR_MESSAGE);
};

View File

@@ -29,7 +29,7 @@ export class CallStateComponentStore<
| (U & CallStateComponentState)
| CallStateComponentState = U extends void
? CallStateComponentState
: U & CallStateComponentState
: U & CallStateComponentState,
> extends ComponentStore<T> {
private error = inject(ERROR_TOKEN);
private flickerTime = inject(FLICKER_TIME);
@@ -39,23 +39,23 @@ export class CallStateComponentStore<
}
readonly isLoading$: Observable<boolean> = this.select(
(state) => state.callState === 'LOADING'
(state) => state.callState === 'LOADING',
);
readonly isLoadingWithFlicker$: Observable<boolean> = this.select(
(state) => state.callState === 'LOADING'
(state) => state.callState === 'LOADING',
).pipe(
switchMap((loading) => nonFlickerLoader(of(loading), this.flickerTime))
switchMap((loading) => nonFlickerLoader(of(loading), this.flickerTime)),
);
readonly isLoaded$: Observable<boolean> = this.select(
(state) => state.callState === 'LOADED'
(state) => state.callState === 'LOADED',
).pipe(switchMap((loaded) => of(loaded)));
readonly callState$ = this.select((state) => state.callState);
readonly error$: Observable<string | undefined> = this.select((state) =>
this.error.getErrorMessage(getErrorCallState(state.callState))
this.error.getErrorMessage(getErrorCallState(state.callState)),
);
readonly updateCallState = this.updater(
@@ -64,7 +64,7 @@ export class CallStateComponentStore<
...(state as object),
callState: callState ?? 'LOADED',
} as T;
}
},
);
readonly startLoading = this.updater(
@@ -74,7 +74,7 @@ export class CallStateComponentStore<
...patchedState,
callState: 'LOADING',
} as T;
}
},
);
readonly stopLoading = this.updater(
@@ -84,12 +84,12 @@ export class CallStateComponentStore<
...patchedState,
callState: 'LOADED',
} as T;
}
},
);
protected handleError(
error: unknown,
patchedState: Partial<U> = {}
patchedState: Partial<U> = {},
): CallStateError {
const err = this.error.toError(error);
this.patchState({

View File

@@ -36,7 +36,7 @@ export interface ErrorState {
export type CallState = LoadingState | ErrorState;
export const getErrorCallState = (
callState: CallState
callState: CallState,
): CustomError | undefined => {
if (isErrorState(callState)) {
return callState.error;

View File

@@ -19,7 +19,7 @@ export const ERROR_TOKEN = new InjectionToken<ErrorHandler<any>>('error', {
});
export const provideErrorHandler = <T extends ErrorHandler<any>>(
errorHandlerClass: Type<T>
errorHandlerClass: Type<T>,
): ClassProvider => ({ provide: ERROR_TOKEN, useClass: errorHandlerClass });
export const FLICKER_TIME = new InjectionToken<number>('flicker', {

View File

@@ -5,16 +5,16 @@ import { combineLatest, map, mapTo, Observable, startWith, timer } from 'rxjs';
*/
export const nonFlickerLoader = (
data$: Observable<boolean>,
duration = 300
duration = 300,
): Observable<boolean> => {
const isTrueWhileDuration$ = timer(duration).pipe(
mapTo(false),
startWith(true)
startWith(true),
);
return combineLatest([data$, isTrueWhileDuration$]).pipe(
map(([data, isTrueWhileDuration]) =>
isTrueWhileDuration ? isTrueWhileDuration : data
)
isTrueWhileDuration ? isTrueWhileDuration : data,
),
);
};

View File

@@ -22,7 +22,7 @@ function describeDestroyService() {
if (!destroy$) {
throw new Error(
'It seems that you forgot to provide DestroyService. Add "provideDestroyService()" to your declarable\'s providers.'
'It seems that you forgot to provide DestroyService. Add "provideDestroyService()" to your declarable\'s providers.',
);
}