From 81d9f5ff68c2c8340f1ca0f922d2f279653a0f1c Mon Sep 17 00:00:00 2001 From: Tanu Chahal Date: Wed, 18 Dec 2024 00:38:40 +0530 Subject: [PATCH] Made shouldDisplayEditButton() a pure function. --- extension-requests/script.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/extension-requests/script.js b/extension-requests/script.js index e029c8c6..d139a6f4 100644 --- a/extension-requests/script.js +++ b/extension-requests/script.js @@ -916,7 +916,7 @@ async function createExtensionCard(data, dev) { attributes: { class: 'edit-button', 'data-testid': 'edit-button' }, }); if (dev) { - if (shouldDisplayEditButton(data.assigneeId)) { + if (shouldDisplayEditButton(data.assigneeId, currentUserDetails)) { extensionCardButtons.appendChild(editButton); } } else { @@ -1455,11 +1455,10 @@ async function createExtensionCard(data, dev) { } } -function shouldDisplayEditButton(assigneeId) { +function shouldDisplayEditButton(assigneeId, currentUserData) { return ( - currentUserDetails && - (assigneeId === currentUserDetails.id || - currentUserDetails.roles.super_user) + currentUserData && + (assigneeId === currentUserData.id || currentUserData.roles.super_user) ); }