mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-24 00:59:35 -06:00
Fix: unify POSTs when toggling sidebar to prevent db lock (#12129)
This commit is contained in:
@@ -243,9 +243,19 @@ describe('AppFrameComponent', () => {
|
|||||||
|
|
||||||
it('should support toggling slim sidebar and saving', fakeAsync(() => {
|
it('should support toggling slim sidebar and saving', fakeAsync(() => {
|
||||||
const saveSettingSpy = jest.spyOn(settingsService, 'set')
|
const saveSettingSpy = jest.spyOn(settingsService, 'set')
|
||||||
|
settingsService.set(SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED, [])
|
||||||
expect(component.slimSidebarEnabled).toBeFalsy()
|
expect(component.slimSidebarEnabled).toBeFalsy()
|
||||||
expect(component.slimSidebarAnimating).toBeFalsy()
|
expect(component.slimSidebarAnimating).toBeFalsy()
|
||||||
component.toggleSlimSidebar()
|
component.toggleSlimSidebar()
|
||||||
|
const requests = httpTestingController.match(
|
||||||
|
`${environment.apiBaseUrl}ui_settings/`
|
||||||
|
)
|
||||||
|
expect(requests).toHaveLength(1)
|
||||||
|
expect(requests[0].request.body.settings.slim_sidebar).toBe(true)
|
||||||
|
expect(
|
||||||
|
requests[0].request.body.settings.attributes_sections_collapsed
|
||||||
|
).toEqual(['attributes'])
|
||||||
|
requests[0].flush({ success: true })
|
||||||
expect(component.slimSidebarAnimating).toBeTruthy()
|
expect(component.slimSidebarAnimating).toBeTruthy()
|
||||||
tick(200)
|
tick(200)
|
||||||
expect(component.slimSidebarAnimating).toBeFalsy()
|
expect(component.slimSidebarAnimating).toBeFalsy()
|
||||||
@@ -254,6 +264,10 @@ describe('AppFrameComponent', () => {
|
|||||||
SETTINGS_KEYS.SLIM_SIDEBAR,
|
SETTINGS_KEYS.SLIM_SIDEBAR,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
expect(saveSettingSpy).toHaveBeenCalledWith(
|
||||||
|
SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED,
|
||||||
|
['attributes']
|
||||||
|
)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
it('should show error on toggle slim sidebar if store settings fails', () => {
|
it('should show error on toggle slim sidebar if store settings fails', () => {
|
||||||
|
|||||||
@@ -140,10 +140,24 @@ export class AppFrameComponent
|
|||||||
|
|
||||||
toggleSlimSidebar(): void {
|
toggleSlimSidebar(): void {
|
||||||
this.slimSidebarAnimating = true
|
this.slimSidebarAnimating = true
|
||||||
this.slimSidebarEnabled = !this.slimSidebarEnabled
|
const slimSidebarEnabled = !this.slimSidebarEnabled
|
||||||
if (this.slimSidebarEnabled) {
|
this.settingsService.set(SETTINGS_KEYS.SLIM_SIDEBAR, slimSidebarEnabled)
|
||||||
this.attributesSectionsCollapsed = true
|
if (slimSidebarEnabled) {
|
||||||
|
this.settingsService.set(SETTINGS_KEYS.ATTRIBUTES_SECTIONS_COLLAPSED, [
|
||||||
|
CollapsibleSection.ATTRIBUTES,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
this.settingsService
|
||||||
|
.storeSettings()
|
||||||
|
.pipe(first())
|
||||||
|
.subscribe({
|
||||||
|
error: (error) => {
|
||||||
|
this.toastService.showError(
|
||||||
|
$localize`An error occurred while saving settings.`
|
||||||
|
)
|
||||||
|
console.warn(error)
|
||||||
|
},
|
||||||
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.slimSidebarAnimating = false
|
this.slimSidebarAnimating = false
|
||||||
}, 200) // slightly longer than css animation for slim sidebar
|
}, 200) // slightly longer than css animation for slim sidebar
|
||||||
|
|||||||
Reference in New Issue
Block a user