The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
[BUGFIX] Reply button opens google (#10269)
Guillimdca4fc1423e6
diff --git a/packages/twenty-front/src/modules/accounts/types/MessageChannel.ts b/packages/twenty-front/src/modules/accounts/types/MessageChannel.tsindex 87d7752834f..5695d7fd817 100644--- a/packages/twenty-front/src/modules/accounts/types/MessageChannel.ts+++ b/packages/twenty-front/src/modules/accounts/types/MessageChannel.ts@@ -1,3 +1,4 @@+import { ConnectedAccountProvider } from 'twenty-shared';import { MessageChannelVisibility } from '~/generated/graphql';export enum MessageChannelContactAutoCreationPolicy {@@ -36,5 +37,9 @@ export type MessageChannel = {syncCursor: string;syncStageStartedAt: Date;throttleFailureCount: number;+ connectedAccount?: {+ id: string;+ provider: ConnectedAccountProvider;+ };__typename: 'MessageChannel';};diff --git a/packages/twenty-front/src/modules/activities/emails/right-drawer/components/RightDrawerEmailThread.tsx b/packages/twenty-front/src/modules/activities/emails/right-drawer/components/RightDrawerEmailThread.tsxindex 1ac7fb65194..92b3fdc7ee2 100644--- a/packages/twenty-front/src/modules/activities/emails/right-drawer/components/RightDrawerEmailThread.tsx+++ b/packages/twenty-front/src/modules/activities/emails/right-drawer/components/RightDrawerEmailThread.tsx@@ -13,6 +13,8 @@ import { RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID } from '@/ui/layout/right-drawerimport { messageThreadState } from '@/ui/layout/right-drawer/states/messageThreadState';import { useClickOutsideListener } from '@/ui/utilities/pointer-event/hooks/useClickOutsideListener';import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';+import { assertUnreachable } from '@/workflow/utils/assertUnreachable';+import { ConnectedAccountProvider } from 'twenty-shared';import { Button, IconArrowBackUp } from 'twenty-ui';const StyledWrapper = styled.div`@@ -52,6 +54,7 @@ export const RightDrawerEmailThread = () => {messageThreadExternalId,connectedAccountHandle,messageChannelLoading,+ connectedAccountProvider,} = useRightDrawerEmailThread();useEffect(() => {@@ -94,17 +97,38 @@ export const RightDrawerEmailThread = () => {const canReply = useMemo(() => {return (- connectedAccountHandle && lastMessage && messageThreadExternalId != null+ connectedAccountHandle &&+ connectedAccountProvider &&+ lastMessage &&+ messageThreadExternalId != null);- }, [connectedAccountHandle, lastMessage, messageThreadExternalId]);+ }, [+ connectedAccountHandle,+ connectedAccountProvider,+ lastMessage,+ messageThreadExternalId,+ ]);const handleReplyClick = () => {if (!canReply) {return;}- const url = `https://mail.google.com/mail/?authuser=${connectedAccountHandle}#all/${messageThreadExternalId}`;- window.open(url, '_blank');+ let url: string;+ switch (connectedAccountProvider) {+ case ConnectedAccountProvider.MICROSOFT:+ url = `https://outlook.office365.com/mail/inbox/id/${messageThreadExternalId}`;+ window.open(url, '_blank');+ break;+ case ConnectedAccountProvider.GOOGLE:+ url = `https://mail.google.com/mail/?authuser=${connectedAccountHandle}#all/${messageThreadExternalId}`;+ window.open(url, '_blank');+ break;+ case null:+ throw new Error('Account provider not provided');+ default:+ assertUnreachable(connectedAccountProvider);+ }};if (!thread || !messages.length) {return null;diff --git a/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts b/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.tsindex 6bfa8f123a7..705dfc8f689 100644--- a/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts+++ b/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts@@ -132,7 +132,10 @@ export const useRightDrawerEmailThread = () => {recordGqlFields: {id: true,handle: true,- connectedAccountId: true,+ connectedAccount: {+ id: true,+ provider: true,+ },},skip: !lastMessageChannelId,});@@ -159,11 +162,17 @@ export const useRightDrawerEmailThread = () => {}).filter(isDefined);+ const connectedAccount =+ messageChannelData.length > 0+ ? messageChannelData[0]?.connectedAccount+ : null;+ const connectedAccountProvider = connectedAccount?.provider ?? null;return {thread,messages: messagesWithSender,messageThreadExternalId,connectedAccountHandle,+ connectedAccountProvider,threadLoading: messagesLoading,messageChannelLoading,fetchMoreMessages,