A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: ensure ui reset of suggestionsLoading when changing docs (#13840)
shamoon3a5312ba6f8f
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.tsindex 30e7a4bdf..471e65487 100644--- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts+++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts@@ -24,7 +24,7 @@ import {} from '@ng-bootstrap/ng-bootstrap'import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'import { DeviceDetectorService } from 'ngx-device-detector'-import { of, throwError } from 'rxjs'+import { Subject, of, throwError } from 'rxjs'import { routes } from 'src/app/app-routing.module'import { Correspondent } from 'src/app/data/correspondent'import { CustomFieldDataType } from 'src/app/data/custom-field'@@ -1444,6 +1444,26 @@ describe('DocumentDetailComponent', () => {})})+ it('should reset the suggestions loading state if the document changes mid-request', () => {+ const getSetting = settingsService.get.bind(settingsService)+ jest+ .spyOn(settingsService, 'get')+ .mockImplementation((key) =>+ key === SETTINGS_KEYS.AI_ENABLED ? true : getSetting(key)+ )+ const pending = new Subject<any>()+ jest+ .spyOn(documentService, 'getAiSuggestions')+ .mockReturnValue(pending.asObservable())+ initNormally()+ expect(component.suggestionsLoading()).toBeTruthy()++ // the in-flight request is cancelled, e.g. by a websocket-driven reload+ component.docChangeNotifier.next(component.documentId())++ expect(component.suggestionsLoading()).toBeFalsy()+ })+it('should show error if needed for get suggestions', () => {const suggestionsSpy = jest.spyOn(documentService, 'getSuggestions')const errorSpy = jest.spyOn(toastService, 'showError')diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.tsindex bb6898a48..d58d7ad1e 100644--- a/src-ui/src/app/components/document-detail/document-detail.component.ts+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts@@ -34,6 +34,7 @@ import {debounceTime,distinctUntilChanged,filter,+ finalize,first,map,switchMap,@@ -1016,16 +1017,15 @@ export class DocumentDetailComponent.pipe(first(),takeUntil(this.unsubscribeNotifier),- takeUntil(this.docChangeNotifier)+ takeUntil(this.docChangeNotifier),+ finalize(() => this.suggestionsLoading.set(false))).subscribe({next: (result) => {this.suggestions.set(result)- this.suggestionsLoading.set(false)},error: (error) => {this.suggestions.set(null)- this.suggestionsLoading.set(false)this.toastService.showError($localize`Error retrieving suggestions.`,error