Offline msg doesn't make sense for auth since it currently only fetches codes on load

This commit is contained in:
Manav Rathi 2024-11-28 16:45:16 +05:30
parent 1178a3c910
commit 9e40d3001a
No known key found for this signature in database
3 changed files with 11 additions and 30 deletions

View File

@ -11,7 +11,6 @@ import {
logStartupBanner,
logUnhandledErrorsAndRejections,
} from "@/base/log-web";
import { MessageContainer } from "@ente/shared/components/MessageContainer";
import { useLocalState } from "@ente/shared/hooks/useLocalState";
import HTTPService from "@ente/shared/network/HTTPService";
import {
@ -36,9 +35,6 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
const router = useRouter();
const [isI18nReady, setIsI18nReady] = useState<boolean>(false);
const [loading, setLoading] = useState(false);
const [offline, setOffline] = useState(
typeof window !== "undefined" && !window.navigator.onLine,
);
const [showNavbar, setShowNavBar] = useState(false);
const { showMiniDialog, miniDialogProps } = useAttributedMiniDialog();
@ -57,9 +53,6 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
return () => logUnhandledErrorsAndRejections(false);
}, []);
const setUserOnline = () => setOffline(false);
const setUserOffline = () => setOffline(true);
useEffect(() => {
router.events.on("routeChangeStart", (url: string) => {
const newPathname = url.split("?")[0];
@ -71,14 +64,6 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
router.events.on("routeChangeComplete", () => {
setLoading(false);
});
window.addEventListener("online", setUserOnline);
window.addEventListener("offline", setUserOffline);
return () => {
window.removeEventListener("online", setUserOnline);
window.removeEventListener("offline", setUserOffline);
};
}, [router]);
const logout = useCallback(() => {
@ -105,9 +90,6 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
<ThemeProvider theme={getTheme(themeColor, "auth")}>
<CssBaseline enableColorScheme />
{showNavbar && <AppNavbar />}
<MessageContainer>
{isI18nReady && offline && t("OFFLINE_MSG")}
</MessageContainer>
<AttributedMiniDialog {...miniDialogProps} />

View File

@ -25,7 +25,6 @@ import { runMigrations } from "@/new/photos/services/migrations";
import { initML, isMLSupported } from "@/new/photos/services/ml";
import { getFamilyPortalRedirectURL } from "@/new/photos/services/user-details";
import { AppContext } from "@/new/photos/types/context";
import { MessageContainer } from "@ente/shared/components/MessageContainer";
import { useLocalState } from "@ente/shared/hooks/useLocalState";
import HTTPService from "@ente/shared/network/HTTPService";
import {
@ -37,7 +36,7 @@ import { getTheme } from "@ente/shared/themes";
import { THEME_COLOR } from "@ente/shared/themes/constants";
import type { User } from "@ente/shared/user/types";
import ArrowForward from "@mui/icons-material/ArrowForward";
import { CssBaseline } from "@mui/material";
import { CssBaseline, styled } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import Notification from "components/Notification";
import { t } from "i18next";
@ -210,9 +209,9 @@ export default function App({ Component, pageProps }: AppProps) {
<ThemeProvider theme={getTheme(themeColor, "photos")}>
<CssBaseline enableColorScheme />
{showNavbar && <AppNavbar />}
<MessageContainer>
<OfflineMessageContainer>
{isI18nReady && offline && t("OFFLINE_MSG")}
</MessageContainer>
</OfflineMessageContainer>
<LoadingBar color="#51cd7c" ref={loadingBarRef} />
<AttributedMiniDialog
@ -249,6 +248,14 @@ export default function App({ Component, pageProps }: AppProps) {
);
}
const OfflineMessageContainer = styled("div")`
background-color: #111;
padding: 0;
font-size: 14px;
text-align: center;
line-height: 32px;
`;
const redirectToFamilyPortal = () =>
void getFamilyPortalRedirectURL().then((url) => {
window.location.href = url;

View File

@ -1,8 +0,0 @@
import { styled } from "@mui/material";
export const MessageContainer = styled("div")`
background-color: #111;
padding: 0;
font-size: 14px;
text-align: center;
line-height: 32px;
`;