mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Prevent double-reload
This commit is contained in:
parent
dc3b79efdc
commit
f114819e65
@ -133,6 +133,29 @@ describe(`Additional service tests for SavedViewService`, () => {
|
|||||||
expect(req.request.body.display_fields).toBeNull()
|
expect(req.request.body.display_fields).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should support patch without reload', () => {
|
||||||
|
subscription = service
|
||||||
|
.patch(
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'Saved View',
|
||||||
|
show_on_dashboard: true,
|
||||||
|
show_in_sidebar: true,
|
||||||
|
sort_field: 'name',
|
||||||
|
sort_reverse: true,
|
||||||
|
filter_rules: [],
|
||||||
|
},
|
||||||
|
false
|
||||||
|
)
|
||||||
|
.subscribe()
|
||||||
|
const req = httpTestingController.expectOne(
|
||||||
|
`${environment.apiBaseUrl}${endpoint}/1/`
|
||||||
|
)
|
||||||
|
expect(req.request.method).toEqual('PATCH')
|
||||||
|
req.flush({})
|
||||||
|
httpTestingController.verify() // no reload
|
||||||
|
})
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Dont need to setup again
|
// Dont need to setup again
|
||||||
|
|
||||||
|
@ -87,15 +87,21 @@ export class SavedViewService extends AbstractPaperlessService<SavedView> {
|
|||||||
return super.create(o).pipe(tap(() => this.reload()))
|
return super.create(o).pipe(tap(() => this.reload()))
|
||||||
}
|
}
|
||||||
|
|
||||||
patch(o: SavedView): Observable<SavedView> {
|
patch(o: SavedView, reload: boolean = false): Observable<SavedView> {
|
||||||
if (o.display_fields?.length === 0) {
|
if (o.display_fields?.length === 0) {
|
||||||
o.display_fields = null
|
o.display_fields = null
|
||||||
}
|
}
|
||||||
return super.patch(o)
|
return super.patch(o).pipe(
|
||||||
|
tap(() => {
|
||||||
|
if (reload) {
|
||||||
|
this.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
patchMany(objects: SavedView[]): Observable<SavedView[]> {
|
patchMany(objects: SavedView[]): Observable<SavedView[]> {
|
||||||
return combineLatest(objects.map((o) => super.patch(o))).pipe(
|
return combineLatest(objects.map((o) => this.patch(o, false))).pipe(
|
||||||
tap(() => this.reload())
|
tap(() => this.reload())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user