Skip to content

Commit

Permalink
Reimplement bug fix, but this time better (maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Jan 21, 2025
1 parent 57fcd09 commit 4389693
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions app/preprints/detail/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 4389693

Please sign in to comment.