Skip to content

Commit

Permalink
Merge branch 'dev' into dependabot/npm_and_yarn/eslint-plugin-jsx-a11…
Browse files Browse the repository at this point in the history
…y-6.8.0
  • Loading branch information
v-almonacid authored Feb 1, 2024
2 parents ca2fe05 + 1a959db commit 66dfb4b
Show file tree
Hide file tree
Showing 74 changed files with 2,510 additions and 364 deletions.
2 changes: 1 addition & 1 deletion packages/frontend/docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ We may now follow these steps:

1. If the staging version has bugs, we'll add bug fixes in the `dev` branch, and version `vX.Y.Z` will be skipped in production. We'll instead move back to step `2.` and try a new hot-fix release `vX.Y.Z+1` including the bug fixes found in staging.

1. If the production version has bugs and a hotfix is needed, we add the bug fixes to a hot-fix branch that stems from the `main` branch. The version of this branch is bumped to `vX.Y.Z-hotfix` and then released to production. Once the hotfix is released, The bug fixes should also be added to the `main` branch
1. If the production version has bugs and a hotfix is needed, we add the bug fixes to a hot-fix branch that stems from the `main` branch. The version of this branch is bumped to `vX.Y.Z-hotfix` and then released to production. Once the hotfix is released, The bug fixes should also be added to the `dev` branch
4 changes: 2 additions & 2 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@alphaday/frontend",
"private": true,
"version": "2.2.2",
"version": "2.3.1",
"type": "module",
"scripts": {
"prepare": "export VITE_COMMIT=$(git rev-parse --short HEAD)",
Expand All @@ -23,7 +23,7 @@
"@capacitor/app": "5.0.6",
"@capacitor/core": "5.4.1",
"@capacitor/haptics": "5.0.6",
"@capacitor/keyboard": "5.0.6",
"@capacitor/keyboard": "5.0.7",
"@capacitor/status-bar": "5.0.6",
"@ionic/react": "7.6.1",
"@ionic/react-router": "7.1.2",
Expand Down
15 changes: 11 additions & 4 deletions packages/frontend/src/MobileApp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { memo } from "react";
import { BrowserRouter, Switch } from "react-router-dom";
import { Suspense, memo } from "react";
import { BrowserRouter, Route, Switch } from "react-router-dom";
import { useAppInit, useGlobalHooks } from "./api/hooks";
import { lazyRetry } from "./api/utils/helpers";
import PreloaderPage from "./pages/preloader";
import "@alphaday/ui-kit/global.scss";

const SuperfeedPage = lazyRetry(() => import("./mobile-pages/superfeed"));

const App: React.FC = () => {
useAppInit();
Expand All @@ -9,8 +14,10 @@ const App: React.FC = () => {
return (
<BrowserRouter>
<Switch>
{/* <Route path="/" exact component={HomePage} /> */}
{/* Add more routes as needed */}
<Suspense fallback={<PreloaderPage />}>
<Route path="/" exact component={SuperfeedPage} />
{/* Add more routes as needed */}
</Suspense>
</Switch>
</BrowserRouter>
);
Expand Down
14 changes: 7 additions & 7 deletions packages/frontend/src/api/hooks/useIsMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ export const useIsMobile = () => {
const isMobileAgent = isMobile();

/**
* If the mobile app feature flag is disabled, we don't want to
* show the mobile view/pwa on prod
* If we are in dev or local, we want to show the mobile view
*/
if (!isMobileEnabled) {
return false;
if (CONFIG.IS_DEV || CONFIG.IS_LOCAL) {
return width < breakpoints.TwoColMinWidth;
}

/**
* If we are in dev or local, we want to show the mobile view
* If the mobile app feature flag is disabled, we don't want to
* show the mobile view/pwa on prod
*/
if (CONFIG.IS_DEV || CONFIG.IS_LOCAL) {
return width < breakpoints.TwoColMinWidth;
if (!isMobileEnabled) {
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC } from "react";
import { ChatProvider } from "./chat-context";
import { DimensionsProvider } from "./dimensions-context";
import { PWAInstallProvider } from "./pwa-install-provider";
import { TutorialProvider } from "./tutorial-context";
import { WalletViewProvider } from "./wallet-view-context";

Expand All @@ -24,6 +25,7 @@ export const AppContextProvider: FC<{ children?: React.ReactNode }> = ({
}) => (
<Compose
providers={[
PWAInstallProvider,
TutorialProvider,
DimensionsProvider,
ChatProvider,
Expand Down
67 changes: 67 additions & 0 deletions packages/frontend/src/api/store/providers/pwa-install-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { createContext, useState, useContext, FC, useCallback } from "react";
import useEventListener from "src/api/hooks/useEventListener";
import { Logger } from "src/api/utils/logging";

const PWAInstallContext = createContext<undefined | (() => void)>(undefined);

const usePWAInstall = () => {
const [eventRef, setEventRef] = useState<Event | null>(null);

const handleInstall = useCallback(() => {
if (eventRef) {
// @ts-ignore - TODO: fix this type
eventRef.prompt();
// @ts-ignore - TODO: fix this type
eventRef.userChoice.then((choiceResult) => {
Logger.debug(
`PWAInstallProvider::useEventListener: user choice: ${choiceResult.outcome}`
);
if (choiceResult.outcome === "accepted") {
Logger.debug(
"PWAInstallProvider::useEventListener: accepted"
);
} else {
Logger.debug(
"PWAInstallProvider::useEventListener: dismissed"
);
}
setEventRef(null);
});
}
}, [eventRef]);

// @ts-ignore - TODO: fix this type
useEventListener("beforeinstallprompt", (e) => {
Logger.debug(
"PWAInstallProvider::useEventListener: beforeinstallprompt triggered"
);
e.preventDefault();
setEventRef(e);
});

return handleInstall;
};

interface PWAInstallProviderProps {
children?: React.ReactNode;
}

const PWAInstallProvider: FC<PWAInstallProviderProps> = ({ children }) => {
const value = usePWAInstall();
return (
<PWAInstallContext.Provider value={value}>
{children}
</PWAInstallContext.Provider>
);
};

const usePWAInstallContext = () => {
const handleInstall = usePWAInstall();
const context = useContext(PWAInstallContext);
if (context === undefined) {
return handleInstall;
}
return context;
};

export { PWAInstallProvider, usePWAInstallContext };
17 changes: 17 additions & 0 deletions packages/frontend/src/assets/icons/logo-shadow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const EventDesc: FC<{ event: TEventDetails; className?: string }> = ({
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(event.description || ""),
}}
className="nine-liner"
className="line-clamp-[9]"
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/podcast/AudioPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const AudioPlayer: FC<IAudioPlayer> = ({
alt={podcast?.sourceName}
/>
<div className="self-start pt-1 flex flex-col pl-[9px] cursor-default">
<span className="fontGroup-highlightSemi one-liner">
<span className="fontGroup-highlightSemi line-clamp-1">
{podcast?.title}
</span>
<span className="fontGroup-mini">
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/components/video/VideoChannelsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const VideoChannelsList: FC<IVideoChannelsList> = ({
src={channel.icon}
alt=""
/>
<span className="relative overflow-hidden pt-1 three-liner fontGroup-support">
<span className="relative overflow-hidden pt-1 line-clamp-3 fontGroup-support">
{channel.name}
</span>
</div>
Expand Down Expand Up @@ -271,7 +271,7 @@ const VideoChannelsList: FC<IVideoChannelsList> = ({
src={channel.icon}
alt=""
/>
<span className="relative overflow-hidden fontGroup-supportBold three-liner">
<span className="relative overflow-hidden fontGroup-supportBold line-clamp-3">
{channel.name}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/video/VideoModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const VideoModule: FC<IVideoModule> = memo(function VideoModule({
/>

<div
className="transition-all duration-300 bg-background relative z-[1] [&_.title]:three-liner"
className="transition-all duration-300 bg-background relative z-[1] [&_.title]:line-clamp-3"
style={{
height:
widgetHeight - SWITCH_HEIGHT - channelsHeight,
Expand Down
52 changes: 52 additions & 0 deletions packages/frontend/src/containers/dialogs/InstallPWAContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { FC, useState } from "react";
import { Button, Modal } from "@alphaday/ui-kit";
import { useIsMobile } from "src/api/hooks/useIsMobile";
import { usePWAInstallContext } from "src/api/store/providers/pwa-install-provider";
import { isPWA } from "src/api/utils/helpers";
import { ReactComponent as CloseSVG } from "../../assets/icons/close3.svg";
import { ReactComponent as LogoShadowSVG } from "../../assets/icons/logo-shadow.svg";

const InstallPWAContainer: FC = () => {
const handleInstall = usePWAInstallContext();
const isMobile = useIsMobile();
const [showModal, setShowModal] = useState(!isPWA());

const handleCloseDialog = () => setShowModal(false);

return (
<Modal
size="sm"
showModal={isMobile && showModal}
className="p-8 m-8 rounded-xl"
onClose={handleCloseDialog}
>
<div className="flex justify-end">
<button
onClick={handleCloseDialog}
className="flex items-center justify-center -m-3.5 -mt-7"
title="close"
type="button"
data-testid="alpha-dialog-close-button"
>
<CloseSVG className="h-4 w-4 text-primary outline-none" />
</button>
</div>
<div className="w-full flex flex-col items-center justify-center">
<span className="bg-secondaryOrange w-40 h-40 m-5 rounded-full flex flex-col items-center justify-center">
<LogoShadowSVG />
</span>
<p className="m-4 text-base font-semibold text-center">
Add Alphaday to your Home screen
</p>
<Button
className="w-full bg-secondaryOrange border-secondaryOrange text-base font-semibold p-3 h-fit"
onClick={handleInstall}
>
Install
</Button>
</div>
</Modal>
);
};

export default InstallPWAContainer;
17 changes: 17 additions & 0 deletions packages/frontend/src/layout/MobileLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FC, ReactNode } from "react";
import { NavBottom, NavHeader, ScrollBar } from "@alphaday/ui-kit";

const MobileLayout: FC<{
children: ReactNode;
onScroll?: () => void;
}> = ({ children, onScroll }) => {
return (
<ScrollBar className="h-screen" onScroll={onScroll}>
<NavHeader avatar={undefined} />
{children}
<NavBottom />
</ScrollBar>
);
};

export default MobileLayout;
18 changes: 13 additions & 5 deletions packages/frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./polyfills";
import { Suspense } from "react";
import * as Sentry from "@sentry/react";
import { BrowserTracing } from "@sentry/tracing";
import { createRoot } from "react-dom/client";
Expand All @@ -12,11 +13,15 @@ import { wagmiConfig } from "./api/store/providers/wallet-connect-provider";
// TODO (xavier-charles): add themes support import ThemeProvider from "./api/store/providers/theme-provider";
import { store } from "./api/store/store";
import { ECookieChoice } from "./api/types";
import { lazyRetry } from "./api/utils/helpers";
import { Logger } from "./api/utils/logging";
import App from "./App";
import CONFIG from "./config";
import InstallPWAContainer from "./containers/dialogs/InstallPWAContainer";
import SeoContainer from "./containers/seo/SeoContainer";
import MobileApp from "./MobileApp";
import PreloaderPage from "./pages/preloader";

const MobileApp = lazyRetry(() => import("./MobileApp"));
const App = lazyRetry(() => import("./App"));

/**
* at this point, the store is still not loaded and we can't read the state
Expand Down Expand Up @@ -66,7 +71,11 @@ if (CONFIG.CLARITY.ENABLE) {

const AppSwitcher = () => {
const isMobile = useIsMobile();
return isMobile ? <MobileApp /> : <App />;
return (
<Suspense fallback={<PreloaderPage />}>
{isMobile ? <MobileApp /> : <App />}
</Suspense>
);
};

const container = document.getElementById("root");
Expand All @@ -80,12 +89,11 @@ root.render(
<PersistProvider>
<SeoContainer />
<AppContextProvider>
{/* <ThemeProvider> */}
<WagmiConfig config={wagmiConfig}>
<AppSwitcher />
</WagmiConfig>
{/* </ThemeProvider> */}
</AppContextProvider>
</PersistProvider>
<InstallPWAContainer />
</Provider>
);
Loading

0 comments on commit 66dfb4b

Please sign in to comment.