Skip to content

Commit

Permalink
fix(frontend): remove intercom on thread page of mobile (#3108)
Browse files Browse the repository at this point in the history
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
  • Loading branch information
Zewed authored Aug 28, 2024
1 parent b7a081e commit a989c05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 1 addition & 4 deletions frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ const RootLayout = async ({

return (
<html lang="en">
<body
className={styles.body}
// className={`bg-white text-black h-screen flex flex-col dark:bg-black dark:text-white w-full ${inter.className}`}
>
<body className={styles.body}>
<ToastProvider>
<SupabaseProvider session={session}>
<App>{children}</App>
Expand Down
11 changes: 9 additions & 2 deletions frontend/lib/helpers/intercom/IntercomProvider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { usePathname } from "next/navigation";
import { useEffect } from "react";

import { useDevice } from "@/lib/hooks/useDevice";
import { useUserData } from "@/lib/hooks/useUserData";

import {
boot as bootIntercom,
load as loadIntercom,
shutdown as shutdownIntercom,
update as updateIntercom,
} from "./intercom";

Expand All @@ -16,13 +18,18 @@ export const IntercomProvider = ({
}): React.ReactNode => {
const pathname = usePathname();
const { userData } = useUserData();
const { isMobile } = useDevice();

if (
typeof window !== "undefined" &&
process.env.NEXT_PUBLIC_INTERCOM_APP_ID
) {
loadIntercom();
bootIntercom(userData?.email ?? "");
if (isMobile && pathname?.includes("/chat")) {
shutdownIntercom();
} else {
loadIntercom();
bootIntercom(userData?.email ?? "");
}
}

useEffect(() => {
Expand Down
4 changes: 4 additions & 0 deletions frontend/lib/helpers/intercom/intercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export const boot = (email: string): void => {
export const update = (): void => {
window && (window as any).Intercom && (window as any).Intercom("update");
};

export const shutdown = (): void => {
window && (window as any).Intercom && (window as any).Intercom("shutdown");
};

0 comments on commit a989c05

Please sign in to comment.