Skip to content

Commit

Permalink
feat: do not use rxjs >= 7 exclusive feature to not break backward co… (
Browse files Browse the repository at this point in the history
#1521)

Co-authored-by: Markiewic <[email protected]>
  • Loading branch information
Markiewic and Markiewic authored Feb 15, 2024
1 parent 17a841c commit b058fd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
20 changes: 10 additions & 10 deletions libs/cdk/excel/src/excel.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@angular/core';
import { exclude } from '@angular-ru/cdk/array';
import { Nullable, PlainObject } from '@angular-ru/cdk/typings';
import { firstValueFrom, Observable, of } from 'rxjs';
import { Observable, of } from 'rxjs';

import { EntriesKeys } from './domain/entries-keys';
import { ExcelBuilderTextColumnInterceptor } from './domain/excel-builder-text-column-interceptor';
Expand All @@ -19,16 +19,16 @@ export class ExcelService {
) {}

public exportExcel<T>(workbook: Partial<ExcelWorkbook<T>>): void {
firstValueFrom(
this.getTranslatedColumn()
// eslint-disable-next-line rxjs/no-topromise
).then(async (translatedKeys: Nullable<PlainObject>): Promise<void> => {
await this.builder.exportExcelByWorkbook({
filename: this.interceptFilename<T>(workbook),
worksheets: this.interceptWorksheets<T>(workbook),
translatedKeys: translatedKeys ?? workbook.translatedKeys ?? {}
this.getTranslatedColumn()
// eslint-disable-next-line rxjs/no-topromise, deprecation/deprecation
.toPromise()
.then(async (translatedKeys: Nullable<PlainObject>): Promise<void> => {
await this.builder.exportExcelByWorkbook({
filename: this.interceptFilename<T>(workbook),
worksheets: this.interceptWorksheets<T>(workbook),
translatedKeys: translatedKeys ?? workbook.translatedKeys ?? {}
});
});
});
}

private interceptFilename<T>(workbook: Partial<ExcelWorkbook<T>>): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EmptyValue, Nullable, PlainObject } from '@angular-ru/cdk/typings';
import { copyHtml, isNotNil } from '@angular-ru/cdk/utils';
import { WebWorkerThreadService } from '@angular-ru/cdk/webworker';
import { TranslateService } from '@ngx-translate/core';
import { firstValueFrom, Observable, of } from 'rxjs';
import { Observable, of } from 'rxjs';

import { RulesDescriptor } from '../plain-table-composer/interfaces/rules-descriptor';
import { PlainTableComposerService } from '../plain-table-composer/plain-table-composer.service';
Expand Down Expand Up @@ -123,8 +123,11 @@ export class TableClipboardService {
const lang: Nullable<string> = this.translate.currentLang ?? this.translate.defaultLang;
const translationMap$: Observable<PlainObject> = isNotNil(lang) ? this.translate.getTranslation(lang) : of({});

return firstValueFrom(translationMap$).then(
(map: PlainObject): PlainObject => this.plainTableComposer.composeSingle(map)
return (
translationMap$
// eslint-disable-next-line rxjs/no-topromise, deprecation/deprecation
.toPromise()
.then((map: PlainObject | nil): PlainObject => this.plainTableComposer.composeSingle(map!))
);
}
}

0 comments on commit b058fd7

Please sign in to comment.