Skip to content

Commit 7981156

Browse files
committed
StrictNullChecks
1 parent bc8ddf3 commit 7981156

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/app/components/admin/stats/stats.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ export class AdminStatsComponent implements OnInit, OnDestroy {
157157
let popularProducts: Array<{'id': string, 'count': number}> = [];
158158

159159
for (const product of products) {
160-
if (popularProducts.find(x => x.id === product.product)) {
161-
popularProducts.find(x => x.id === product.product).count += 1;
160+
const updateProduct = popularProducts.find(x => x.id === product.product);
161+
162+
if (updateProduct) {
163+
updateProduct.count += 1;
162164
} else {
163165
popularProducts.push(
164166
{
@@ -199,8 +201,10 @@ export class AdminStatsComponent implements OnInit, OnDestroy {
199201
let popularPages: Array<{'name': string, 'count': number}> = [];
200202

201203
for (const page of pages) {
202-
if (popularPages.find(x => x.name === page.page)) {
203-
popularPages.find(x => x.name === page.page).count += 1;
204+
const updatePage = popularPages.find(x => x.name === page.page);
205+
206+
if (updatePage) {
207+
updatePage.count += 1;
204208
} else {
205209
popularPages.push(
206210
{

0 commit comments

Comments
 (0)