immediately show the appended "sent from shellphone" signature

This commit is contained in:
m5r 2021-10-21 00:39:40 +02:00
parent 950a7e1bd0
commit e00f0bde64
2 changed files with 8 additions and 6 deletions

View File

@ -19,7 +19,7 @@ type Props = {
}; };
const NewMessageArea: FunctionComponent<Props> = ({ recipient, onSend }) => { const NewMessageArea: FunctionComponent<Props> = ({ recipient, onSend }) => {
const { organization } = useCurrentUser(); const { organization, hasOngoingSubscription } = useCurrentUser();
const phoneNumber = useCurrentPhoneNumber(); const phoneNumber = useCurrentPhoneNumber();
const sendMessageMutation = useMutation(sendMessage)[0]; const sendMessageMutation = useMutation(sendMessage)[0];
const { setQueryData: setConversationsQueryData, refetch: refetchConversations } = useQuery( const { setQueryData: setConversationsQueryData, refetch: refetchConversations } = useQuery(
@ -48,7 +48,9 @@ const NewMessageArea: FunctionComponent<Props> = ({ recipient, onSend }) => {
phoneNumberId: phoneNumber!.id, phoneNumberId: phoneNumber!.id,
from: phoneNumber!.number, from: phoneNumber!.number,
to: recipient, to: recipient,
content: content, content: hasOngoingSubscription
? content
: content + "\n\nSent from Shellphone (https://www.shellphone.app)",
direction: Direction.Outbound, direction: Direction.Outbound,
status: MessageStatus.Queued, status: MessageStatus.Queued,
sentAt: new Date(), sentAt: new Date(),

View File

@ -47,10 +47,10 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({
}, },
}); });
const isFreeSubscription = !subscription; const hasOngoingSubscription = Boolean(subscription);
const messageBody = isFreeSubscription const messageBody = hasOngoingSubscription
? content + "\n\nSent from Shellphone (https://www.shellphone.app)" ? content
: content; : content + "\n\nSent from Shellphone (https://www.shellphone.app)";
const phoneNumberId = phoneNumber.id; const phoneNumberId = phoneNumber.id;
const message = await db.message.create({ const message = await db.message.create({
data: { data: {