From 438969336b5adf24c247b5a7d0965bd398520f02 Mon Sep 17 00:00:00 2001 From: futa-ikeda Date: Tue, 21 Jan 2025 10:09:56 -0500 Subject: [PATCH] Reimplement bug fix, but this time better (maybe) --- app/preprints/detail/route.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts index 79f99ea1be..c1ed0c56ea 100644 --- a/app/preprints/detail/route.ts +++ b/app/preprints/detail/route.ts @@ -96,20 +96,22 @@ export default class PreprintsDetail extends Route { let hasPendingWithdrawal = false; let latestWithdrawalRequest = null; let latestAction = null; - if (preprintWithdrawableState && preprint.currentUserIsAdmin) { + if (preprint.currentUserPermissions.length > 0) { const reviewActions = await preprint?.queryHasMany('reviewActions'); latestAction = reviewActions.firstObject; - const withdrawalRequests = await preprint?.queryHasMany('requests'); - latestWithdrawalRequest = withdrawalRequests.firstObject; - if (latestWithdrawalRequest) { - hasPendingWithdrawal = latestWithdrawalRequest.machineState === 'pending'; - const requestActions = await withdrawalRequests.firstObject?.queryHasMany('actions', { - sort: '-modified', - }); - latestAction = requestActions.firstObject; - // @ts-ignore: ActionTrigger is never - if (latestAction && latestAction.actionTrigger === 'reject') { - isWithdrawalRejected = true; + if (preprintWithdrawableState && preprint.currentUserIsAdmin) { + const withdrawalRequests = await preprint?.queryHasMany('requests'); + latestWithdrawalRequest = withdrawalRequests.firstObject; + if (latestWithdrawalRequest) { + hasPendingWithdrawal = latestWithdrawalRequest.machineState === 'pending'; + const requestActions = await withdrawalRequests.firstObject?.queryHasMany('actions', { + sort: '-modified', + }); + latestAction = requestActions.firstObject; + // @ts-ignore: ActionTrigger is never + if (latestAction && latestAction.actionTrigger === 'reject') { + isWithdrawalRejected = true; + } } } }