Fix: saved view sidebar heading not always visible (#7584)

This commit is contained in:
shamoon
2024-08-30 15:43:08 -07:00
committed by GitHub
parent dad3a1ff28
commit b8283047ae
5 changed files with 95 additions and 78 deletions

View File

@@ -69,6 +69,16 @@ describe(`Additional service tests for SavedViewService`, () => {
expect(service.sidebarViews).toHaveLength(3)
})
it('should gracefully handle errors', () => {
service.initialize()
const req = httpTestingController.expectOne(
`${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000`
)
req.error(new ErrorEvent('error'))
expect(service.loading).toBeFalsy()
expect(service.allViews).toHaveLength(0)
})
it('should support patchMany', () => {
subscription = service.patchMany(saved_views).subscribe()
saved_views.forEach((saved_view) => {

View File

@@ -3,7 +3,6 @@ import { Injectable } from '@angular/core'
import { combineLatest, Observable } from 'rxjs'
import { tap } from 'rxjs/operators'
import { SavedView } from 'src/app/data/saved-view'
import { PermissionsService } from '../permissions.service'
import { AbstractPaperlessService } from './abstract-paperless-service'
import { SettingsService } from '../settings.service'
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
@@ -12,11 +11,11 @@ import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
providedIn: 'root',
})
export class SavedViewService extends AbstractPaperlessService<SavedView> {
loading: boolean
public loading: boolean = true
private savedViews: SavedView[] = []
constructor(
http: HttpClient,
permissionService: PermissionsService,
protected http: HttpClient,
private settingsService: SettingsService
) {
super(http, 'saved_views')
@@ -27,16 +26,19 @@ export class SavedViewService extends AbstractPaperlessService<SavedView> {
}
private reload() {
this.loading = true
this.listAll().subscribe((r) => {
this.savedViews = r.results
this.loading = false
this.settingsService.dashboardIsEmpty = this.dashboardViews.length === 0
this.listAll().subscribe({
next: (r) => {
this.savedViews = r.results
this.loading = false
this.settingsService.dashboardIsEmpty = this.dashboardViews.length === 0
},
error: () => {
this.loading = false
this.settingsService.dashboardIsEmpty = true
},
})
}
private savedViews: SavedView[] = []
get allViews() {
return this.savedViews
}