From e6b76f705d4356a09c4c78cbe7fc8576e55fe653 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 4 Apr 2022 08:52:39 +0200 Subject: [PATCH] MOBILE-3833 user-menu: Fix blink effect in handlers --- .../mainmenu/components/user-menu/user-menu.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.ts b/src/core/features/mainmenu/components/user-menu/user-menu.ts index c84bc642a..e3cda789c 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.ts +++ b/src/core/features/mainmenu/components/user-menu/user-menu.ts @@ -79,12 +79,15 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { return; } - this.handlers = []; - handlers.forEach((handler) => { - if (handler.type == CoreUserDelegateService.TYPE_NEW_PAGE) { - this.handlers.push(handler.data); - } - }); + const newHandlers = handlers + .filter((handler) => handler.type === CoreUserDelegateService.TYPE_NEW_PAGE) + .map((handler) => handler.data); + + // Only update handlers if they have changed, to prevent a blink effect. + if (newHandlers.length !== this.handlers.length || + JSON.stringify(newHandlers) !== JSON.stringify(this.handlers)) { + this.handlers = newHandlers; + } this.handlersLoaded = CoreUserDelegate.areHandlersLoaded(this.user.id, CoreUserDelegateContext.USER_MENU); });