From e3f0a37f912b7acd4cb357bb1cbf0e7ac790a230 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 19 Apr 2025 21:57:06 -0700 Subject: [PATCH] Just start the frontend [ci skip] --- .../document-detail.component.ts | 43 +++++++++++-------- src-ui/src/app/data/document-suggestions.ts | 2 + 2 files changed, 27 insertions(+), 18 deletions(-) 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.ts index 2f5b179b8..0a3d9ec38 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 @@ -74,6 +74,7 @@ import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { DocumentService } from 'src/app/services/rest/document.service' import { StoragePathService } from 'src/app/services/rest/storage-path.service' +import { TagService } from 'src/app/services/rest/tag.service' import { UserService } from 'src/app/services/rest/user.service' import { SettingsService } from 'src/app/services/settings.service' import { ToastService } from 'src/app/services/toast.service' @@ -262,6 +263,7 @@ export class DocumentDetailComponent constructor( private documentsService: DocumentService, private route: ActivatedRoute, + private tagService: TagService, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private router: Router, @@ -645,25 +647,30 @@ export class DocumentDetailComponent PermissionType.Document ) ) { - this.documentsService - .getSuggestions(doc.id) - .pipe( - first(), - takeUntil(this.unsubscribeNotifier), - takeUntil(this.docChangeNotifier) - ) - .subscribe({ - next: (result) => { - this.suggestions = result - }, - error: (error) => { - this.suggestions = null - this.toastService.showError( - $localize`Error retrieving suggestions.`, - error + this.tagService.getCachedMany(doc.tags).subscribe((tags) => { + // only show suggestions if document has inbox tags + if (tags.some((tag) => tag.is_inbox_tag)) { + this.documentsService + .getSuggestions(doc.id) + .pipe( + first(), + takeUntil(this.unsubscribeNotifier), + takeUntil(this.docChangeNotifier) ) - }, - }) + .subscribe({ + next: (result) => { + this.suggestions = result + }, + error: (error) => { + this.suggestions = null + this.toastService.showError( + $localize`Error retrieving suggestions.`, + error + ) + }, + }) + } + }) } this.title = this.documentTitlePipe.transform(doc.title) const docFormValues = Object.assign({}, doc) diff --git a/src-ui/src/app/data/document-suggestions.ts b/src-ui/src/app/data/document-suggestions.ts index 85f9f9d22..8c7aca515 100644 --- a/src-ui/src/app/data/document-suggestions.ts +++ b/src-ui/src/app/data/document-suggestions.ts @@ -1,4 +1,6 @@ export interface DocumentSuggestions { + title?: string + tags?: number[] correspondents?: number[]