mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
Fix: saved view sidebar heading not always visible (#7584)
This commit is contained in:
@@ -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) => {
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user