]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Refactor to use Angular inject() for service injection, remove log line
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 2 Jul 2025 18:18:08 +0000 (11:18 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Wed, 2 Jul 2025 18:18:08 +0000 (11:18 -0700)
src-ui/src/app/components/chat/chat/chat.component.ts
src-ui/src/app/services/chat.service.ts

index 7ab29b3665fae71da649e82fc7a92571b259859a..b59bae9f022ed7ad274341f173dc705216d3ffcf 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
+import { Component, ElementRef, inject, OnInit, ViewChild } from '@angular/core'
 import { FormsModule, ReactiveFormsModule } from '@angular/forms'
 import { NavigationEnd, Router } from '@angular/router'
 import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
@@ -23,6 +23,9 @@ export class ChatComponent implements OnInit {
   public input: string = ''
   public documentId!: number
 
+  private chatService: ChatService = inject(ChatService)
+  private router: Router = inject(Router)
+
   @ViewChild('scrollAnchor') scrollAnchor!: ElementRef<HTMLDivElement>
   @ViewChild('chatInput') chatInput!: ElementRef<HTMLInputElement>
 
@@ -35,11 +38,6 @@ export class ChatComponent implements OnInit {
       : $localize`Ask a question about a document...`
   }
 
-  constructor(
-    private chatService: ChatService,
-    private router: Router
-  ) {}
-
   ngOnInit(): void {
     this.updateDocumentId(this.router.url)
     this.router.events
@@ -48,8 +46,6 @@ export class ChatComponent implements OnInit {
         map((event) => (event as NavigationEnd).url)
       )
       .subscribe((url) => {
-        console.log('URL changed:', url)
-
         this.updateDocumentId(url)
       })
   }
index 5c9307db6a1fa03e9513c7eb5bf20b6394496124..9ddfb83300c88d14d61cb7bb221139c19d6f361f 100644 (file)
@@ -3,7 +3,7 @@ import {
   HttpDownloadProgressEvent,
   HttpEventType,
 } from '@angular/common/http'
-import { Injectable } from '@angular/core'
+import { inject, Injectable } from '@angular/core'
 import { filter, map, Observable } from 'rxjs'
 import { environment } from 'src/environments/environment'
 
@@ -17,7 +17,7 @@ export interface ChatMessage {
   providedIn: 'root',
 })
 export class ChatService {
-  constructor(private http: HttpClient) {}
+  private http: HttpClient = inject(HttpClient)
 
   streamChat(documentId: number, prompt: string): Observable<string> {
     return this.http