Skip to content

Commit

Permalink
🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Dec 2, 2024
1 parent 2b4ae2e commit f3976ca
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN foundryup
WORKDIR /usr/src/app
COPY . .
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
RUN pnpm expo export --platform web --source-maps --output-dir server/app && \
RUN pnpm expo export --dev --no-minify --platform web --source-maps --output-dir server/app && \
pnpm run --filter server build && \
pnpm deploy --filter server --prod /prod/server

Expand Down
2 changes: 2 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "dotenv/config";
import type { IntercomPluginProps } from "@intercom/intercom-react-native/lib/typescript/expo-plugins/@types";
import type { withSentry } from "@sentry/react-native/expo";
import type { ExpoConfig } from "expo/config";
import type { AssetProps } from "expo-asset/plugin/build/withAssets";
import type { PluginConfigType as BuildPropertiesConfig } from "expo-build-properties/build/pluginConfig";
import type withCamera from "expo-camera/plugin/build/withCamera";
import type { FontProps } from "expo-font/plugin/build/withFonts";
Expand Down Expand Up @@ -96,6 +97,7 @@ export default {
],
} satisfies FontProps,
],
["expo-asset", { assets: ["src/assets/icon.png"] } satisfies AssetProps],
"expo-router",
[
"@intercom/intercom-react-native",
Expand Down
24 changes: 24 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/web-manifest.json",
"short_name": "Exa",
"name": "Exa",
"icons": [
{ "src": "favicon.ico", "type": "image/x-icon", "sizes": "48x48" },
{ "src": "assets/src/assets/icon.f9538ae2aa18c66272006c460191b34f.png", "type": "image/png", "sizes": "1024x1024" }
],
"id": "/",
"lang": "en",
"start_url": ".",
"display": "standalone",
"orientation": "portrait",
"theme_color": "#0BD8B6",
"background_color": "#171918",
"prefer_related_applications": true,
"related_applications": [
{
"platform": "play",
"id": "app.exactly",
"url": "https://play.google.com/store/apps/details?id=app.exactly"
}
]
}
1 change: 1 addition & 0 deletions src/app/+html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function HTML({ children }: { children: ReactNode }) {
name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover"
/>
<link rel="manifest" href="/manifest.json" />
<ScrollViewStyleReset />
</head>
<body>{children}</body>
Expand Down
4 changes: 4 additions & 0 deletions src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ToastProvider } from "@tamagui/toast";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
import { isRunningInExpoGo } from "expo";
import { useAssets } from "expo-asset";
import { type FontSource, useFonts } from "expo-font";
import { SplashScreen, Stack, useNavigationContainerRef } from "expo-router";
import React, { useEffect } from "react";
Expand All @@ -17,6 +18,7 @@ import BDOGroteskRegular from "../assets/fonts/BDOGrotesk-Regular.otf";
import IBMPlexMonoBold from "../assets/fonts/IBMPlexMono-Bold.otf";
import IBMPlexMonoRegular from "../assets/fonts/IBMPlexMono-Regular.otf";
import IBMPlexMonoSemiBold from "../assets/fonts/IBMPlexMono-SemiBold.otf";
import AppIcon from "../assets/icon.png";
import { OnboardingProvider } from "../components/context/OnboardingProvider";
import ThemeProvider from "../components/context/ThemeProvider";
import handleError from "../utils/handleError";
Expand All @@ -42,6 +44,7 @@ init({
spotlight: __DEV__,
});
const useServerFonts = typeof window === "undefined" ? useFonts : () => undefined;
const useServerAssets = typeof window === "undefined" ? useAssets : () => undefined;
const devtools = !!JSON.parse(process.env.EXPO_PUBLIC_DEVTOOLS ?? "false");

export default wrap(function RootLayout() {
Expand All @@ -54,6 +57,7 @@ export default wrap(function RootLayout() {
"IBMPlexMono-Regular": IBMPlexMonoRegular as FontSource,
"IBMPlexMono-SemiBold": IBMPlexMonoSemiBold as FontSource,
});
useServerAssets([AppIcon]);
useEffect(() => {
routingInstrumentation.registerNavigationContainer(navigationContainer);
}, [navigationContainer]);
Expand Down
2 changes: 2 additions & 0 deletions src/components/onboarding/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import qrCodeBlob from "../../assets/images/qr-code-blob.svg";
import qrCode from "../../assets/images/qr-code.svg";
import alchemyConnector from "../../utils/alchemyConnector";
import handleError from "../../utils/handleError";
import { enablePrompt } from "../../utils/onesignal";
import queryClient from "../../utils/queryClient";
import { getPasskey } from "../../utils/server";
import ActionButton from "../shared/ActionButton";
Expand Down Expand Up @@ -115,6 +116,7 @@ export default function Carousel() {
onSuccess(passkey) {
queryClient.setQueryData<Passkey>(["passkey"], parse(Passkey, passkey));
connect({ connector: alchemyConnector });
enablePrompt();
router.replace("/(home)");
},
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/onboarding/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StyleSheet } from "react-native";

import AccountCreatedBlob from "../../assets/images/account-created-blob.svg";
import AccountCreatedImage from "../../assets/images/account-created.svg";
import { enablePrompt } from "../../utils/onesignal";
import ActionButton from "../shared/ActionButton";
import SafeView from "../shared/SafeView";
import Text from "../shared/Text";
Expand Down Expand Up @@ -35,6 +36,7 @@ export default function Success() {
marginTop="$s4"
marginBottom="$s5"
onPress={() => {
enablePrompt();
router.replace("/(app)");
}}
iconAfter={<ArrowRight color="$interactiveOnBaseBrandDefault" />}
Expand Down
33 changes: 30 additions & 3 deletions src/utils/onesignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,38 @@ import type * as OneSignalWeb from "react-onesignal";

import handleError from "./handleError";

const { initialization, login, logout } = (
const { initialization, enablePrompt, login, logout } = (
Platform.OS === "web" && typeof window !== "undefined"
? () => {
const { default: OneSignal } = require("react-onesignal") as typeof OneSignalWeb; // eslint-disable-line @typescript-eslint/no-require-imports, unicorn/prefer-module
let displayPrompt: (() => void) | undefined;
return {
initialization: appId
? OneSignal.init({ appId, allowLocalhostAsSecureOrigin: __DEV__ }).catch(handleError)
? OneSignal.init({
appId,
allowLocalhostAsSecureOrigin: __DEV__,
notifyButton: {
enabled: true,
showCredit: false,
displayPredicate: () =>
new Promise((resolve) => {
console.log("1");
displayPrompt = () => {
console.log("2", {
permission: OneSignal.Notifications.permission,
isPushSupported: OneSignal.Notifications.isPushSupported(),
});
resolve(!OneSignal.Notifications.permission && OneSignal.Notifications.isPushSupported());
};
}),
},
}).catch(handleError)
: Promise.resolve(),
enablePrompt: () => {
if (!appId) return;
if (!displayPrompt) throw new Error("uninitialized onesignal");
displayPrompt();
},
login: (userId: string) => {
if (appId) return OneSignal.login(userId);
return Promise.resolve();
Expand All @@ -30,6 +54,9 @@ const { initialization, login, logout } = (
if (appId) OneSignal.initialize(appId);
return Promise.resolve();
})(),
enablePrompt: () => {
if (appId) OneSignal.InAppMessages.addTrigger("onboard", "1");
},
login: (userId: string) => {
if (appId) OneSignal.login(userId);
return Promise.resolve();
Expand All @@ -42,4 +69,4 @@ const { initialization, login, logout } = (
}
)();

export { initialization, login, logout };
export { initialization, enablePrompt, login, logout };

0 comments on commit f3976ca

Please sign in to comment.