Skip to content

armgit / ente

Public Imported from GitHub
0

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

Create albums web app

Anand Baburajan47eb59dc3be1
diff --git a/.github/workflows/web-deploy.yml b/.github/workflows/web-deploy.yml
index 6c71eba817..cd81a490b4 100644
--- a/.github/workflows/web-deploy.yml
+++ b/.github/workflows/web-deploy.yml
@@ -65,16 +65,16 @@ jobs:
command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/photos web/apps/photos/out
- name: Build custom-albums
- run: yarn build:photos
+ run: yarn build:albums
env:
- NEXT_PUBLIC_ENTE_ONLY_SERVE_ALBUMS_APP: 1
+ NEXT_PUBLIC_ENTE_OFFICIAL_ALBUMS_APP: 1
- name: Publish custom-albums
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/custom-albums web/apps/photos/out
+ command: pages deploy --project-name=ente --commit-dirty=true --branch=deploy/custom-albums web/apps/albums/out
- name: Build accounts
run: yarn build:accounts
diff --git a/web/apps/albums/next.config.js b/web/apps/albums/next.config.js
new file mode 100644
index 0000000000..5a52794ab2
--- /dev/null
+++ b/web/apps/albums/next.config.js
@@ -0,0 +1 @@
+module.exports = require("ente-base/next.config.base.js");
diff --git a/web/apps/albums/package.json b/web/apps/albums/package.json
new file mode 100644
index 0000000000..43ac9f2489
--- /dev/null
+++ b/web/apps/albums/package.json
@@ -0,0 +1,37 @@
+{
+ "name": "albums",
+ "version": "0.0.0",
+ "private": true,
+ "dependencies": {
+ "@hugeicons/core-free-icons": "^1.1.0",
+ "@hugeicons/react": "^1.1.4",
+ "chrono-node": "^2.9.0",
+ "debounce": "^2.2.0",
+ "ente-accounts": "*",
+ "ente-base": "*",
+ "ente-gallery": "*",
+ "ente-media": "*",
+ "ente-new": "*",
+ "ente-wasm": "*",
+ "memoize-one": "^6.0.0",
+ "ml-matrix": "^6.12.1",
+ "p-debounce": "^5.0.0",
+ "react": "^19.2.0",
+ "react-dom": "^19.2.0",
+ "react-leaflet": "^5.0.0",
+ "react-select": "^5.10.2",
+ "react-top-loading-bar": "^3.0.2",
+ "react-virtualized-auto-sizer": "^1.0.26",
+ "react-window": "^1.8.11",
+ "sanitize-filename": "^1.6.3",
+ "similarity-transformation": "^0.0.1",
+ "supercluster": "^8.0.1"
+ },
+ "devDependencies": {
+ "@types/node": "^22.15.32",
+ "@types/react": "^19.2.2",
+ "@types/react-dom": "^19.2.2",
+ "@types/react-window": "^1.8.8",
+ "ente-build-config": "*"
+ }
+}
diff --git a/web/apps/albums/src/pages/404.tsx b/web/apps/albums/src/pages/404.tsx
new file mode 100644
index 0000000000..6897a1afe6
--- /dev/null
+++ b/web/apps/albums/src/pages/404.tsx
@@ -0,0 +1 @@
+export { default } from "ente-base/components/pages/404";
diff --git a/web/apps/albums/src/pages/_app.tsx b/web/apps/albums/src/pages/_app.tsx
new file mode 100644
index 0000000000..cfcd8896b4
--- /dev/null
+++ b/web/apps/albums/src/pages/_app.tsx
@@ -0,0 +1 @@
+export { default } from "../../../photos/src/pages/_app";
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/albums/src/pages/index.tsx
similarity index 98%
rename from web/apps/photos/src/pages/shared-albums.tsx
rename to web/apps/albums/src/pages/index.tsx
index 5a56cf19ed..623e104e8a 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/albums/src/pages/index.tsx
@@ -53,8 +53,9 @@ import {
import log from "ente-base/log";
import {
albumsAppOrigin,
+ isOfficialAlbumsApp,
isCustomAlbumsAppOrigin,
- shouldOnlyServeAlbumsApp,
+ photosAppOrigin,
} from "ente-base/origins";
import { FullScreenDropZone } from "ente-gallery/components/FullScreenDropZone";
import {
@@ -189,6 +190,10 @@ export default function PublicCollectionGallery() {
continue: {
text: t("login"),
action: async () => {
+ if (isOfficialAlbumsApp) {
+ window.location.href = photosAppOrigin();
+ return;
+ }
await router.push("/");
},
},
@@ -203,7 +208,7 @@ export default function PublicCollectionGallery() {
const checkAndRedirectForTripAlbum = (collection: Collection): boolean => {
if (
collection.pubMagicMetadata?.data.layout === "trip" &&
- shouldOnlyServeAlbumsApp
+ isOfficialAlbumsApp
) {
const currentURL = new URL(window.location.href);
const albumsURL = new URL(albumsAppOrigin());
@@ -222,22 +227,6 @@ export default function PublicCollectionGallery() {
};
useEffect(() => {
- const currentURL = new URL(window.location.href);
- if (currentURL.pathname != "/") {
- router.replace(
- {
- pathname: "/shared-albums",
- search: currentURL.search,
- hash: currentURL.hash,
- },
- {
- pathname: "/",
- search: currentURL.search,
- hash: currentURL.hash,
- },
- { shallow: true },
- );
- }
/**
* Determine credentials, read the locally cached state, then start
* pulling the latest from remote.
diff --git a/web/apps/albums/tsconfig.json b/web/apps/albums/tsconfig.json
new file mode 100644
index 0000000000..dad3f93a38
--- /dev/null
+++ b/web/apps/albums/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "extends": "ente-build-config/tsconfig-next.json",
+ "compilerOptions": {
+ "baseUrl": "../photos/src"
+ },
+ "include": [
+ "next-env.d.ts",
+ "src/**/*.ts",
+ "src/**/*.tsx",
+ "src/**/*.js",
+ "../photos/src/**/*.ts",
+ "../photos/src/**/*.tsx",
+ "../photos/src/**/*.js",
+ "../../packages/base/components/utils/mui-theme.d.ts",
+ "../../packages/base/global-electron.d.ts"
+ ],
+ "exclude": ["node_modules", "out", ".next", ".next-desktop"]
+}
diff --git a/web/apps/photos/src/pages/index.tsx b/web/apps/photos/src/pages/index.tsx
index 873883b842..ca358b313e 100644
--- a/web/apps/photos/src/pages/index.tsx
+++ b/web/apps/photos/src/pages/index.tsx
@@ -8,11 +8,7 @@ import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { useBaseContext } from "ente-base/context";
import log from "ente-base/log";
-import {
- albumsAppOrigin,
- customAPIHost,
- shouldOnlyServeAlbumsApp,
-} from "ente-base/origins";
+import { customAPIHost } from "ente-base/origins";
import {
masterKeyFromSession,
updateSessionFromElectronSafeStorageIfNeeded,
@@ -111,29 +107,11 @@ const Page: React.FC = () => {
}
}
- const albumsURL = new URL(albumsAppOrigin());
- currentURL.pathname = router.pathname;
- if (
- (shouldOnlyServeAlbumsApp ||
- currentURL.host == albumsURL.host) &&
- currentURL.pathname != "/shared-albums"
- ) {
- const [hash] = currentURL.hash.slice(1).split("&", 1);
- await router.replace({
- pathname: "/shared-albums",
- search: currentURL.search,
- hash: hash,
- });
- } else {
- await updateSessionFromElectronSafeStorageIfNeeded();
- if (
- (await masterKeyFromSession()) &&
- (await savedAuthToken())
- ) {
- await router.push("/gallery");
- } else if (savedPartialLocalUser()?.email) {
- await router.push("/verify");
- }
+ await updateSessionFromElectronSafeStorageIfNeeded();
+ if ((await masterKeyFromSession()) && (await savedAuthToken())) {
+ await router.push("/gallery");
+ } else if (savedPartialLocalUser()?.email) {
+ await router.push("/verify");
}
if (!(await canAccessIndexedDB())) {
showMiniDialog({
diff --git a/web/package.json b/web/package.json
index c2dc2374b2..b2398f7ca7 100644
--- a/web/package.json
+++ b/web/package.json
@@ -9,6 +9,7 @@
"scripts": {
"build": "yarn build:photos",
"build:accounts": "yarn build:wasm && yarn workspace accounts next build",
+ "build:albums": "yarn build:wasm && yarn workspace albums next build",
"build:auth": "yarn build:wasm && yarn workspace auth next build",
"build:cast": "yarn build:wasm && yarn workspace cast next build",
"build:embed": "yarn build:wasm && yarn workspace embed next build",
@@ -22,7 +23,7 @@
"build:wasm": "yarn workspace ente-wasm build --no-pack",
"dev": "yarn dev:photos",
"dev:accounts": "yarn build:wasm && yarn workspace accounts next dev -p 3001",
- "dev:albums": "yarn build:wasm && yarn workspace photos next dev -p 3002",
+ "dev:albums": "yarn build:wasm && yarn workspace albums next dev -p 3002",
"dev:auth": "yarn build:wasm && yarn workspace auth next dev -p 3003",
"dev:cast": "yarn build:wasm && yarn workspace cast next dev -p 3004",
"dev:embed": "yarn build:wasm && yarn workspace embed next dev -p 3006",
diff --git a/web/packages/accounts-rs/services/redirect.ts b/web/packages/accounts-rs/services/redirect.ts
index bfe9ae7031..5b601c08a5 100644
--- a/web/packages/accounts-rs/services/redirect.ts
+++ b/web/packages/accounts-rs/services/redirect.ts
@@ -7,6 +7,7 @@ import { appName } from "ente-base/app";
*/
export const appHomeRoute: string = {
accounts: "/passkeys",
+ albums: "/",
auth: "/auth",
cast: "/" /* The cast app doesn't use this, this is an arbitrary value. */,
embed: "/" /* The embed app doesn't use this either. */,
diff --git a/web/packages/accounts/services/redirect.ts b/web/packages/accounts/services/redirect.ts
index bfe9ae7031..5b601c08a5 100644
--- a/web/packages/accounts/services/redirect.ts
+++ b/web/packages/accounts/services/redirect.ts
@@ -7,6 +7,7 @@ import { appName } from "ente-base/app";
*/
export const appHomeRoute: string = {
accounts: "/passkeys",
+ albums: "/",
auth: "/auth",
cast: "/" /* The cast app doesn't use this, this is an arbitrary value. */,
embed: "/" /* The embed app doesn't use this either. */,
diff --git a/web/packages/base/app.ts b/web/packages/base/app.ts
index d7b6f9ccdc..0556caaca9 100644
--- a/web/packages/base/app.ts
+++ b/web/packages/base/app.ts
@@ -1,5 +1,6 @@
export const appNames = [
"accounts",
+ "albums",
"auth",
"cast",
"embed",
@@ -63,6 +64,7 @@ export const desktopAppVersion = process.env.desktopAppVersion;
*/
export const staticAppTitle = {
accounts: "Ente Accounts",
+ albums: "Ente Photos",
auth: "Ente Auth",
cast: "Ente Photos",
embed: "Ente Photos",
@@ -89,6 +91,7 @@ export const clientPackageName = (() => {
}
return {
accounts: "io.ente.accounts.web",
+ albums: "io.ente.albums.web",
auth: "io.ente.auth.web",
cast: "io.ente.cast.web",
embed: "io.ente.photos.web", // Use photos package name for embed app
diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.ts
index b8efcafb21..45877a620a 100644
--- a/web/packages/base/origins.ts
+++ b/web/packages/base/origins.ts
@@ -99,10 +99,10 @@ export const albumsAppOrigin = () =>
process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT ?? "https://albums.ente.io";
/**
- * Return true if this build is meant to only serve public albums.
+ * Return true if this build is Ente's official public albums deployment.
*/
-export const shouldOnlyServeAlbumsApp =
- !!process.env.NEXT_PUBLIC_ENTE_ONLY_SERVE_ALBUMS_APP;
+export const isOfficialAlbumsApp =
+ !!process.env.NEXT_PUBLIC_ENTE_OFFICIAL_ALBUMS_APP;
/**
* A static build time constant that is `true` if {@link shareAppOrigin} has
diff --git a/web/packages/gallery/components/viewer/CommentsSidebar.tsx b/web/packages/gallery/components/viewer/CommentsSidebar.tsx
index 6e778834eb..c26add8e5a 100644
--- a/web/packages/gallery/components/viewer/CommentsSidebar.tsx
+++ b/web/packages/gallery/components/viewer/CommentsSidebar.tsx
@@ -15,7 +15,7 @@ import {
import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
import type { PublicAlbumsCredentials } from "ente-base/http";
import log from "ente-base/log";
-import { shouldOnlyServeAlbumsApp } from "ente-base/origins";
+import { isOfficialAlbumsApp } from "ente-base/origins";
import { downloadManager } from "ente-gallery/services/download";
import { getAvatarColor } from "ente-gallery/utils/avatar-colors";
import type { EnteFile } from "ente-media/file";
@@ -661,7 +661,7 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({
}, [file, fileNormalCollectionIDs]);
// Check if this is a public album
- const isPublicAlbum = shouldOnlyServeAlbumsApp || !!publicAlbumsCredentials;
+ const isPublicAlbum = isOfficialAlbumsApp || !!publicAlbumsCredentials;
// Build collection info list with comment counts and cover files (shared albums only)
const collectionsInfo = useMemo((): CollectionInfo[] => {
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index af543417a5..8197acbf59 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -35,7 +35,7 @@ import { lowercaseExtension } from "ente-base/file-name";
import type { PublicAlbumsCredentials } from "ente-base/http";
import { formattedListJoin, ut } from "ente-base/i18n";
import log from "ente-base/log";
-import { shouldOnlyServeAlbumsApp } from "ente-base/origins";
+import { isOfficialAlbumsApp } from "ente-base/origins";
import {
FileInfo,
type FileInfoExif,
@@ -792,7 +792,7 @@ export const FileViewer: React.FC<FileViewerProps> = ({
const activeAnnotatedFileRef = useRef(activeAnnotatedFile);
activeAnnotatedFileRef.current = activeAnnotatedFile;
- const isPublicAlbum = shouldOnlyServeAlbumsApp || !!publicAlbumsCredentials;
+ const isPublicAlbum = isOfficialAlbumsApp || !!publicAlbumsCredentials;
// Called when the like button (heart) is clicked.
// - If public album: toggle like (unlike if already liked, else show modal)