Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Trim unused albums app shell

Anand Baburajanbc9a0ac55beb
diff --git a/web/apps/albums/src/pages/_app.tsx b/web/apps/albums/src/pages/_app.tsx
index 460a644f47..998e58a358 100644
--- a/web/apps/albums/src/pages/_app.tsx
+++ b/web/apps/albums/src/pages/_app.tsx
@@ -4,17 +4,10 @@ import { ThemeProvider } from "@mui/material/styles";
import { useNotification } from "components/utils/hooks-app";
import { staticAppTitle } from "ente-base/app";
import { CustomHeadPhotosOrAlbums } from "ente-base/components/Head";
-import {
- LoadingIndicator,
- TranslucentLoadingOverlay,
-} from "ente-base/components/loaders";
+import { LoadingIndicator } from "ente-base/components/loaders";
import { AttributedMiniDialog } from "ente-base/components/MiniDialog";
import { useAttributedMiniDialog } from "ente-base/components/utils/dialog";
-import {
- useIsRouteChangeInProgress,
- useSetupI18n,
- useSetupLogs,
-} from "ente-base/components/utils/hooks-app";
+import { useSetupI18n } from "ente-base/components/utils/hooks-app";
import { photosTheme } from "ente-base/components/utils/theme";
import { BaseContext, deriveBaseContext } from "ente-base/context";
import { Notification } from "ente-new/photos/components/Notification";
@@ -23,7 +16,7 @@ import { useLoadingBar } from "ente-new/photos/components/utils/use-loading-bar"
import { PhotosAppContext } from "ente-new/photos/types/context";
import { t } from "i18next";
import type { AppProps } from "next/app";
-import { useMemo, useState } from "react";
+import { useMemo } from "react";
import "photoswipe/dist/photoswipe.css";
import "styles/global.css";
@@ -32,38 +25,22 @@ import "styles/photoswipe.css";
type AlbumsAppProps = AppProps<Record<string, unknown>>;
const App: React.FC<AlbumsAppProps> = ({ Component, pageProps }) => {
- useSetupLogs();
-
const isI18nReady = useSetupI18n();
- const isChangingRoute = useIsRouteChangeInProgress();
const { showMiniDialog, miniDialogProps } = useAttributedMiniDialog();
const { showNotification, notificationProps } = useNotification();
const { loadingBarRef, showLoadingBar, hideLoadingBar } = useLoadingBar();
- const [watchFolderView, setWatchFolderView] = useState(false);
const baseContext = useMemo(
- () =>
- deriveBaseContext({
- logout: () => {},
- showMiniDialog,
- }),
+ () => deriveBaseContext({ showMiniDialog }),
[showMiniDialog],
);
const appContext = useMemo(
() => ({
showLoadingBar,
hideLoadingBar,
- watchFolderView,
- setWatchFolderView,
showNotification,
}),
- [
- showLoadingBar,
- hideLoadingBar,
- watchFolderView,
- setWatchFolderView,
- showNotification,
- ],
+ [showLoadingBar, hideLoadingBar, showNotification],
);
const title = isI18nReady ? t("title_photos") : staticAppTitle;
@@ -82,10 +59,7 @@ const App: React.FC<AlbumsAppProps> = ({ Component, pageProps }) => {
{!isI18nReady ? (
<LoadingIndicator />
) : (
- <>
- {isChangingRoute && <TranslucentLoadingOverlay />}
- <Component {...pageProps} />
- </>
+ <Component {...pageProps} />
)}
</PhotosAppContext>
</BaseContext>
diff --git a/web/apps/albums/vendor/ente-base/components/utils/hooks-app.ts b/web/apps/albums/vendor/ente-base/components/utils/hooks-app.ts
index 3c738a1781..89a3033ef3 100644
--- a/web/apps/albums/vendor/ente-base/components/utils/hooks-app.ts
+++ b/web/apps/albums/vendor/ente-base/components/utils/hooks-app.ts
@@ -1,7 +1,4 @@
import { setupI18n } from "ente-base/i18n";
-import { disableDiskLogs } from "ente-base/log";
-import { logUnhandledErrorsAndRejections } from "ente-base/log-web";
-import { useRouter } from "next/router";
import { useEffect, useState } from "react";
/**
@@ -22,58 +19,3 @@ export const useSetupI18n = () => {
return isI18nReady;
};
-
-interface SetupLoggingOptions {
- /** If true, then the logs will not be saved to local storage. */
- disableDiskLogs?: boolean;
-}
-
-/**
- * A hook that initializes the logging subsystem.
- *
- * This is only meant to be called from the top level `_app.tsx`, as this
- * initialization is intended to happen only once for the lifetime of the app.
- *
- * @param opts Optional {@link SetupLoggingOptions} to customize the setup.
- */
-export const useSetupLogs = (opts?: SetupLoggingOptions) => {
- useEffect(() => {
- if (opts?.disableDiskLogs) disableDiskLogs();
- logUnhandledErrorsAndRejections(true);
- return () => logUnhandledErrorsAndRejections(false);
- }, []);
-};
-
-/**
- * A hook that keeps track of whether or not we are in the middle of a Next.js
- * route change.
- *
- * The top level app component uses this to show a loading indicator.
- */
-export const useIsRouteChangeInProgress = () => {
- const router = useRouter();
- const [loading, setLoading] = useState(false);
-
- useEffect(() => {
- const handleRouteChangeStart = (url: string) => {
- const newPathname = url.split("?")[0];
- if (window.location.pathname !== newPathname) {
- setLoading(true);
- }
- };
-
- const handleRouteChangeComplete = () => {
- setLoading(false);
- };
-
- router.events.on("routeChangeStart", handleRouteChangeStart);
- router.events.on("routeChangeComplete", handleRouteChangeComplete);
-
- return () => {
- router.events.off("routeChangeStart", handleRouteChangeStart);
- router.events.off("routeChangeComplete", handleRouteChangeComplete);
- };
- }, [router]);
-
- return loading;
-};
diff --git a/web/apps/albums/vendor/ente-base/context.ts b/web/apps/albums/vendor/ente-base/context.ts
index ca3ee1fda6..19ed2f023a 100644
--- a/web/apps/albums/vendor/ente-base/context.ts
+++ b/web/apps/albums/vendor/ente-base/context.ts
@@ -10,10 +10,6 @@ import log from "./log";
* It is usually provided by the _app.tsx for the corresponding app.
*/
export interface BaseContextT {
- /**
- * Perform the (possibly app specific) logout sequence.
- */
- logout: () => void;
/**
* Show a "mini dialog" with the given attributes.
*
@@ -41,14 +37,13 @@ export const BaseContext = createContext<BaseContextT | undefined>(undefined);
export const useBaseContext = (): BaseContextT => useContext(BaseContext)!;
/**
- * A helper function to create a {@link BaseContext} by deriving derivable
- * context values from the minimal subset.
+ * A helper function to create a {@link BaseContext} by deriving the generic
+ * error handler from the provided {@link showMiniDialog}.
*
* In simpler words, it automatically provides a definition of
* {@link onGenericError} using the given {@link showMiniDialog} prop.
*/
export const deriveBaseContext = ({
- logout,
showMiniDialog,
}: Omit<BaseContextT, "onGenericError">): BaseContextT => {
const onGenericError = (e: unknown) => {
@@ -63,5 +58,5 @@ export const deriveBaseContext = ({
}, 0);
};
- return { logout, showMiniDialog, onGenericError };
+ return { showMiniDialog, onGenericError };
};
diff --git a/web/apps/albums/vendor/ente-new/photos/types/context.ts b/web/apps/albums/vendor/ente-new/photos/types/context.ts
index 15ced6b718..e36c033828 100644
--- a/web/apps/albums/vendor/ente-new/photos/types/context.ts
+++ b/web/apps/albums/vendor/ente-new/photos/types/context.ts
@@ -19,8 +19,6 @@ export interface PhotosAppContextT {
* using the provided {@link NotificationAttributes}.
*/
showNotification: (attributes: NotificationAttributes) => void;
- watchFolderView: boolean;
- setWatchFolderView: (isOpen: boolean) => void;
}
/**
diff --git a/web/apps/albums/vendor/photos/components/Upload.tsx b/web/apps/albums/vendor/photos/components/Upload.tsx
index e23395aa00..d32a1f336b 100644
--- a/web/apps/albums/vendor/photos/components/Upload.tsx
+++ b/web/apps/albums/vendor/photos/components/Upload.tsx
@@ -194,7 +194,7 @@ export const Upload: React.FC<UploadProps> = ({
...props
}) => {
const { showMiniDialog, onGenericError } = useBaseContext();
- const { showNotification, watchFolderView } = usePhotosAppContext();
+ const { showNotification } = usePhotosAppContext();
const [uploadProgressView, setUploadProgressView] = useState(false);
const [
@@ -432,12 +432,6 @@ export const Upload: React.FC<UploadProps> = ({
// Handle selected files when user selects files for upload through the open
// file / open folder selection dialog, or drag-and-drops them.
useEffect(() => {
- if (watchFolderView) {
- // if watch folder dialog is open don't catch the dropped file
- // as they are folder being dropped for watching
- return;
- }
-
let files: File[];
isDragAndDrop.current = false;