From 8da8b2586ffaea4ff2228a587363bce61884edb5 Mon Sep 17 00:00:00 2001 From: Tom Shaw Date: Fri, 17 Nov 2023 20:03:38 -0600 Subject: [PATCH] Linting rule fixes. --- .eslintrc.json | 3 +- .../glyph-list/glyph-list.component.ts | 45 +++++++++++-------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 35ff0c8..cd58a64 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -40,8 +40,7 @@ "@typescript-eslint/no-floating-promises": 0, "@typescript-eslint/no-unnecessary-type-assertion": 0, "@typescript-eslint/unbound-method": 0, - "@typescript-eslint/no-inferrable-types": 0, - "@typescript-eslint/require-await": 0 + "@typescript-eslint/no-inferrable-types": 0 } }, { diff --git a/src/app/shared/components/glyph-list/glyph-list.component.ts b/src/app/shared/components/glyph-list/glyph-list.component.ts index 699b39e..c77615b 100644 --- a/src/app/shared/components/glyph-list/glyph-list.component.ts +++ b/src/app/shared/components/glyph-list/glyph-list.component.ts @@ -62,26 +62,33 @@ export class GlyphListComponent implements OnInit, OnChanges { this.paginate().then(() => this.initGlyphList(0)); } - async paginate() { - const numGlyphs: number = this.fontObject.numGlyphs; - const numPages: number = Math.ceil(numGlyphs / this.cellCount); - - const data = []; - for (let i = 0; i < numPages; i++) { - const lastIndex = Math.min(numGlyphs - 1, (i + 1) * this.cellCount - 1); - const text = i * this.cellCount + '-' + lastIndex; - data.push({ - key: i, - value: text - }); - } - - this.paginatorOptions = data; - this.numGlyphs = numGlyphs - 1; - this.numPages = numPages; - - return data; + paginate() { + return new Promise((resolve, reject) => { + try { + const numGlyphs: number = this.fontObject.numGlyphs; + const numPages: number = Math.ceil(numGlyphs / this.cellCount); + + const data = []; + for (let i = 0; i < numPages; i++) { + const lastIndex = Math.min(numGlyphs - 1, (i + 1) * this.cellCount - 1); + const text = i * this.cellCount + '-' + lastIndex; + data.push({ + key: i, + value: text + }); + } + + this.paginatorOptions = data; + this.numGlyphs = numGlyphs - 1; + this.numPages = numPages; + + resolve(data); + } catch (error) { + reject(error); + } + }); } + initGlyphList(page: number = 0) { const firstGlyph = page * this.cellCount;