From 00aa6c1f6a5417e03d5732f4dd1de42769bcf88e Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 17 Nov 2023 09:41:00 -0800 Subject: [PATCH] Fix: Always retrieve sidebar views from service (#4619) --- .../app/components/app-frame/app-frame.component.html | 4 ++-- .../app/components/app-frame/app-frame.component.ts | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index 49220d0ab..a710600ef 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -87,12 +87,12 @@ </li> </ul> <ng-container *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.SavedView }"> - <h6 class="sidebar-heading px-3 mt-3 mb-1 text-muted" *ngIf='savedViewService.loading || sidebarViews?.length > 0'> + <h6 class="sidebar-heading px-3 mt-3 mb-1 text-muted" *ngIf='savedViewService.loading || savedViewService.sidebarViews?.length > 0'> <span i18n>Saved views</span> <div *ngIf="savedViewService.loading" class="spinner-border spinner-border-sm fw-normal ms-2" role="status"></div> </h6> <ul class="nav flex-column mb-2" cdkDropList (cdkDropListDropped)="onDrop($event)"> - <li class="nav-item w-100" *ngFor="let view of sidebarViews" + <li class="nav-item w-100" *ngFor="let view of savedViewService.sidebarViews" cdkDrag [cdkDragDisabled]="!settingsService.organizingSidebarSavedViews" cdkDragPreviewContainer="parent" diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts index d7a093271..0c8f149c1 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.ts @@ -58,8 +58,6 @@ export class AppFrameComponent searchField = new FormControl('') - sidebarViews: PaperlessSavedView[] - constructor( public router: Router, private activatedRoute: ActivatedRoute, @@ -90,10 +88,6 @@ export class AppFrameComponent this.checkForUpdates() } this.tasksService.reload() - - this.savedViewService.listAll().subscribe(() => { - this.sidebarViews = this.savedViewService.sidebarViews - }) } toggleSlimSidebar(): void { @@ -240,9 +234,10 @@ export class AppFrameComponent } onDrop(event: CdkDragDrop<PaperlessSavedView[]>) { - moveItemInArray(this.sidebarViews, event.previousIndex, event.currentIndex) + const sidebarViews = this.savedViewService.sidebarViews.concat([]) + moveItemInArray(sidebarViews, event.previousIndex, event.currentIndex) - this.settingsService.updateSidebarViewsSort(this.sidebarViews).subscribe({ + this.settingsService.updateSidebarViewsSort(sidebarViews).subscribe({ next: () => { this.toastService.showInfo($localize`Sidebar views updated`) },