From 020b4c5eea971949749110324a3fc77b5acddb75 Mon Sep 17 00:00:00 2001 From: k00b Date: Thu, 19 Sep 2024 14:06:34 -0500 Subject: [PATCH] allow comment updates when they have boost --- api/paidAction/boost.js | 2 +- api/resolvers/item.js | 2 +- api/typeDefs/item.js | 2 +- components/use-item-submit.js | 2 +- fragments/paidAction.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/paidAction/boost.js b/api/paidAction/boost.js index eed017d6..fd2a3260 100644 --- a/api/paidAction/boost.js +++ b/api/paidAction/boost.js @@ -49,7 +49,7 @@ export async function onPaid ({ invoice, actId }, { models, tx }) { }) itemAct = await tx.itemAct.findFirst({ where: { invoiceId: invoice.id } }) } else if (actId) { - itemAct = await tx.itemAct.findFirst({ where: { id: { in: actId } } }) + itemAct = await tx.itemAct.findFirst({ where: { id: actId } }) } else { throw new Error('No invoice or actId') } diff --git a/api/resolvers/item.js b/api/resolvers/item.js index fc8a1b03..63d97796 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -1375,7 +1375,7 @@ export const updateItem = async (parent, { sub: subName, forward, hash, hmac, .. item = { id: Number(item.id), text: item.text, title: `@${user.name}'s bio` } } else if (old.parentId) { // prevent editing a comment like a post - item = { id: Number(item.id), text: item.text } + item = { id: Number(item.id), text: item.text, boost: item.boost } } else { item = { subName, ...item } item.forwardUsers = await getForwardUsers(models, forward) diff --git a/api/typeDefs/item.js b/api/typeDefs/item.js index 56046b91..c70b84c8 100644 --- a/api/typeDefs/item.js +++ b/api/typeDefs/item.js @@ -57,7 +57,7 @@ export default gql` id: ID, sub: String, title: String!, text: String, options: [String!]!, boost: Int, forward: [ItemForwardInput], pollExpiresAt: Date, hash: String, hmac: String): ItemPaidAction! updateNoteId(id: ID!, noteId: String!): Item! - upsertComment(id: ID, text: String!, parentId: ID, hash: String, hmac: String): ItemPaidAction! + upsertComment(id: ID, text: String!, parentId: ID, boost: Int, hash: String, hmac: String): ItemPaidAction! act(id: ID!, sats: Int, act: String, idempotent: Boolean): ItemActPaidAction! pollVote(id: ID!): PollVotePaidAction! toggleOutlaw(id: ID!): Item! diff --git a/components/use-item-submit.js b/components/use-item-submit.js index 23c3849b..f460c51a 100644 --- a/components/use-item-submit.js +++ b/components/use-item-submit.js @@ -44,7 +44,7 @@ export default function useItemSubmit (mutation, variables: { id: item?.id, sub: item?.subName || sub?.name, - boost: boost ? Number(boost) : undefined, + boost: boost ? Number(boost) : item?.boost ? Number(item.boost) : undefined, bounty: bounty ? Number(bounty) : undefined, status: status === 'STOPPED' ? 'STOPPED' : 'ACTIVE', title: title?.trim(), diff --git a/fragments/paidAction.js b/fragments/paidAction.js index b1fc246f..ed8cbb91 100644 --- a/fragments/paidAction.js +++ b/fragments/paidAction.js @@ -218,8 +218,8 @@ export const CREATE_COMMENT = gql` export const UPDATE_COMMENT = gql` ${ITEM_PAID_ACTION_FIELDS} ${PAID_ACTION} - mutation upsertComment($id: ID!, $text: String!, ${HASH_HMAC_INPUT_1}) { - upsertComment(id: $id, text: $text, ${HASH_HMAC_INPUT_2}) { + mutation upsertComment($id: ID!, $text: String!, $boost: Int, ${HASH_HMAC_INPUT_1}) { + upsertComment(id: $id, text: $text, boost: $boost, ${HASH_HMAC_INPUT_2}) { ...ItemPaidActionFields ...PaidActionFields }