From e00f0bde64575c9853e922f72c2fccf33ff5c65e Mon Sep 17 00:00:00 2001 From: m5r Date: Thu, 21 Oct 2021 00:39:40 +0200 Subject: [PATCH] immediately show the appended "sent from shellphone" signature --- app/messages/components/new-message-area.tsx | 6 ++++-- app/messages/mutations/send-message.ts | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/messages/components/new-message-area.tsx b/app/messages/components/new-message-area.tsx index 0730a36..e3cd779 100644 --- a/app/messages/components/new-message-area.tsx +++ b/app/messages/components/new-message-area.tsx @@ -19,7 +19,7 @@ type Props = { }; const NewMessageArea: FunctionComponent = ({ recipient, onSend }) => { - const { organization } = useCurrentUser(); + const { organization, hasOngoingSubscription } = useCurrentUser(); const phoneNumber = useCurrentPhoneNumber(); const sendMessageMutation = useMutation(sendMessage)[0]; const { setQueryData: setConversationsQueryData, refetch: refetchConversations } = useQuery( @@ -48,7 +48,9 @@ const NewMessageArea: FunctionComponent = ({ recipient, onSend }) => { phoneNumberId: phoneNumber!.id, from: phoneNumber!.number, to: recipient, - content: content, + content: hasOngoingSubscription + ? content + : content + "\n\nSent from Shellphone (https://www.shellphone.app)", direction: Direction.Outbound, status: MessageStatus.Queued, sentAt: new Date(), diff --git a/app/messages/mutations/send-message.ts b/app/messages/mutations/send-message.ts index 59c512a..d6767a9 100644 --- a/app/messages/mutations/send-message.ts +++ b/app/messages/mutations/send-message.ts @@ -47,10 +47,10 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({ }, }); - const isFreeSubscription = !subscription; - const messageBody = isFreeSubscription - ? content + "\n\nSent from Shellphone (https://www.shellphone.app)" - : content; + const hasOngoingSubscription = Boolean(subscription); + const messageBody = hasOngoingSubscription + ? content + : content + "\n\nSent from Shellphone (https://www.shellphone.app)"; const phoneNumberId = phoneNumber.id; const message = await db.message.create({ data: {