From 5a7d25548f637de18e236a74e743b363c7d6ffc8 Mon Sep 17 00:00:00 2001 From: 4gray Date: Thu, 28 Nov 2024 23:54:50 +0100 Subject: [PATCH] refactor: simplify DataFactory and PwaService dependencies Remove unnecessary parameters from DataFactory and PwaService constructor. The changes streamline the service initialization process by eliminating the unused HttpClient dependency in DataFactory and adjusting PwaService to inject HttpClient directly. This improves code clarity and reduces complexity. --- src/app/app.module.ts | 7 ++----- src/app/services/pwa.service.ts | 16 +++++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 18aa11225..e570de0ca 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -48,17 +48,14 @@ function isTauri() { /** * Conditionally imports the necessary service based on the current environment */ -export function DataFactory( - ngxIndexedDBService: NgxIndexedDBService, - http: HttpClient -) { +export function DataFactory() { if (isElectron()) { return new ElectronService(); } if (isTauri()) { return new TauriService(); } - return new PwaService(http); + return new PwaService(); } @NgModule({ diff --git a/src/app/services/pwa.service.ts b/src/app/services/pwa.service.ts index 7e5f6a1b3..a9aa4dd6b 100644 --- a/src/app/services/pwa.service.ts +++ b/src/app/services/pwa.service.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { ApplicationRef, inject, Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; import { SwUpdate } from '@angular/service-worker'; import { Store } from '@ngrx/store'; @@ -19,23 +19,21 @@ import { Playlist } from '../../../shared/playlist.interface'; import { AppConfig } from '../../environments/environment'; import * as PlaylistActions from '../state/actions'; import { DataService } from './data.service'; -import { PlaylistsService } from './playlists.service'; @Injectable({ providedIn: 'root', }) export class PwaService extends DataService { - appRef = inject(ApplicationRef); - playlistService = inject(PlaylistsService); - snackBar = inject(MatSnackBar); - store = inject(Store); - swUpdate = inject(SwUpdate); - translateService = inject(TranslateService); + private readonly http = inject(HttpClient); + private readonly snackBar = inject(MatSnackBar); + private readonly store = inject(Store); + private readonly swUpdate = inject(SwUpdate); + private readonly translateService = inject(TranslateService); /** Proxy URL to avoid CORS issues */ corsProxyUrl = AppConfig.BACKEND_URL; - constructor(private http: HttpClient) { + constructor() { super(); console.log('PWA service initialized...'); }