mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Fix: handle page out of range in mgmt lists after delete (#8771)
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { DatePipe } from '@angular/common'
|
||||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
|
||||
import {
|
||||
HttpErrorResponse,
|
||||
provideHttpClient,
|
||||
withInterceptorsFromDi,
|
||||
} from '@angular/common/http'
|
||||
import { provideHttpClientTesting } from '@angular/common/http/testing'
|
||||
import {
|
||||
ComponentFixture,
|
||||
@@ -243,6 +247,21 @@ describe('ManagementListComponent', () => {
|
||||
expect(reloadSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should fall back to first page if error is page is out of range', () => {
|
||||
jest.spyOn(tagService, 'listFiltered').mockReturnValueOnce(
|
||||
throwError(
|
||||
() =>
|
||||
new HttpErrorResponse({
|
||||
status: 404,
|
||||
error: { detail: 'Invalid page' },
|
||||
})
|
||||
)
|
||||
)
|
||||
component.page = 2
|
||||
component.reloadData()
|
||||
expect(component.page).toEqual(1)
|
||||
})
|
||||
|
||||
it('should support toggle all items in view', () => {
|
||||
expect(component.selectedObjects.size).toEqual(0)
|
||||
const toggleAllSpy = jest.spyOn(component, 'toggleAll')
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { HttpErrorResponse } from '@angular/common/http'
|
||||
import {
|
||||
Directive,
|
||||
OnDestroy,
|
||||
@@ -152,9 +153,17 @@ export abstract class ManagementListComponent<T extends ObjectWithId>
|
||||
}),
|
||||
delay(100)
|
||||
)
|
||||
.subscribe(() => {
|
||||
this.show = true
|
||||
this.loading = false
|
||||
.subscribe({
|
||||
error: (error: HttpErrorResponse) => {
|
||||
if (error.error?.detail?.includes('Invalid page')) {
|
||||
this.page = 1
|
||||
this.reloadData()
|
||||
}
|
||||
},
|
||||
next: () => {
|
||||
this.show = true
|
||||
this.loading = false
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user