From 5340745fcb347d64e0fc9fc38dae47c585756214 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Thu, 15 Apr 2021 15:15:49 +0100 Subject: [PATCH] fix Flickering viewer toolbar icons when navigating to next/previous files (#2074) --- src/app/components/viewer/viewer.component.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/app/components/viewer/viewer.component.ts b/src/app/components/viewer/viewer.component.ts index 253ea6492..ce894a054 100644 --- a/src/app/components/viewer/viewer.component.ts +++ b/src/app/components/viewer/viewer.component.ts @@ -131,8 +131,13 @@ export class AppViewerComponent implements OnInit, OnDestroy { .subscribe((ruleContext) => { this.selection = ruleContext.selection; - this.toolbarActions = this.extensions.getViewerToolbarActions(); - this.openWith = this.extensions.openWithActions; + if (this.toolbarActions.length === 0) { + this.toolbarActions = this.extensions.getViewerToolbarActions(); + } + + if (this.openWith.length === 0) { + this.openWith = this.extensions.openWithActions; + } }); this.route.params.subscribe((params) => { @@ -200,18 +205,19 @@ export class AppViewerComponent implements OnInit, OnDestroy { return obj.id; } - async displayNode(id: string) { - if (id) { + async displayNode(nodeId: string) { + if (nodeId) { try { - this.node = await this.contentApi.getNodeInfo(id).toPromise(); + this.node = await this.contentApi.getNodeInfo(nodeId).toPromise(); this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }])); if (this.node && this.node.isFile) { + this.nodeId = this.node.id; + const nearest = await this.getNearestNodes(this.node.id, this.node.parentId); this.previousNodeId = nearest.left; this.nextNodeId = nearest.right; - this.nodeId = this.node.id; this.fileName = this.node.name + this.node?.properties?.['cm:versionLabel']; return; } @@ -220,7 +226,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { if (statusCode !== 401) { this.router.navigate([this.previewLocation, { outlets: { viewer: null } }]).then(() => { - this.router.navigate([this.previewLocation, id]); + this.router.navigate([this.previewLocation, nodeId]); }); } }