Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use

Manav Rathi9c8701cd8cd4
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 59966ed4f3..9c288e67c7 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -20,9 +20,6 @@ import {
SearchResultsHeader,
} from "@/new/photos/components/gallery";
import {
- deriveAlbumishFilteredFiles,
- derivePeopleFilteredFiles,
- deriveTrashFilteredFiles,
uniqueFilesByID,
useGalleryReducer,
type GalleryBarMode,
@@ -32,7 +29,6 @@ import { shouldShowWhatsNew } from "@/new/photos/services/changelog";
import {
ALL_SECTION,
DUMMY_UNCATEGORIZED_COLLECTION,
- TRASH_SECTION,
isHiddenCollection,
} from "@/new/photos/services/collection";
import { areOnlySystemCollections } from "@/new/photos/services/collection/ui";
@@ -306,15 +302,7 @@ export default function Gallery() {
const collections = state.collections;
const files = state.files;
const hiddenFiles = state.hiddenFiles;
- const trashedFiles = state.trashedFiles;
- const archivedCollectionIDs = state.archivedCollectionIDs;
- const hiddenFileIDs = state.hiddenFileIDs;
- const collectionNameMap = state.allCollectionNameByID;
- const fileToCollectionsMap = state.fileCollectionIDs;
const collectionSummaries = state.collectionSummaries;
- const hiddenCollectionSummaries = state.hiddenCollectionSummaries;
- const tempDeletedFileIDs = state.tempDeletedFileIDs;
- const tempHiddenFileIDs = state.tempHiddenFileIDs;
const barMode = state.view?.type ?? "albums";
const activeCollectionID =
state.view?.type == "people"
@@ -328,7 +316,7 @@ export default function Gallery() {
const isInSearchMode = state.isInSearchMode;
const filteredFiles = state.filteredFiles;
- if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) console.log("render", { state });
+ if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) console.log("render", state);
const router = useRouter();
@@ -483,51 +471,13 @@ export default function Gallery() {
// TODO: Make this a normal useEffect.
useMemoSingleThreaded(async () => {
- if (
- !files ||
- !user ||
- !trashedFiles ||
- !hiddenFiles ||
- !archivedCollectionIDs
- ) {
- dispatch({
- type: "setFilteredFiles",
- filteredFiles: [],
- });
- return;
- }
-
- let filteredFiles: EnteFile[];
if (selectedSearchOption) {
- filteredFiles = await filterSearchableFiles(
+ const searchResults = await filterSearchableFiles(
selectedSearchOption.suggestion,
);
- } else if (state.view?.type == "people") {
- filteredFiles = derivePeopleFilteredFiles(state, state.view);
- } else if (activeCollectionID === TRASH_SECTION) {
- filteredFiles = deriveTrashFilteredFiles(state);
- } else {
- filteredFiles = deriveAlbumishFilteredFiles(state);
+ dispatch({ type: "setSearchResults", searchResults });
}
-
- dispatch({
- type: "setFilteredFiles",
- filteredFiles,
- });
- }, [
- barMode,
- files,
- trashedFiles,
- hiddenFiles,
- tempDeletedFileIDs,
- tempHiddenFileIDs,
- hiddenFileIDs,
- selectedSearchOption,
- activeCollectionID,
- archivedCollectionIDs,
- peopleState,
- activePersonID,
- ]);
+ }, [selectedSearchOption]);
const selectAll = (e: KeyboardEvent) => {
// ignore ctrl/cmd + a if the user is typing in a text field
@@ -923,8 +873,8 @@ export default function Gallery() {
[],
);
- if (!user || !filteredFiles) {
- // Don't render until we get the logged in user and dispatch "mount".
+ if (!user) {
+ // Don't render until we dispatch "mount" with the logged in user.
return <div></div>;
}
@@ -1046,7 +996,8 @@ export default function Gallery() {
activeCollection,
activeCollectionID,
setActiveCollectionID: handleSetActiveCollectionID,
- hiddenCollectionSummaries,
+ hiddenCollectionSummaries:
+ state.hiddenCollectionSummaries,
showPeopleSectionButton,
people:
(state.view.type == "people"
@@ -1129,8 +1080,8 @@ export default function Gallery() {
activeCollectionID={activeCollectionID}
activePersonID={activePerson?.id}
enableDownload={true}
- fileToCollectionsMap={fileToCollectionsMap}
- collectionNameMap={collectionNameMap}
+ fileToCollectionsMap={state.fileCollectionIDs}
+ collectionNameMap={state.allCollectionNameByID}
showAppDownloadBanner={
files.length < 30 && !isInSearchMode
}
@@ -1185,7 +1136,7 @@ export default function Gallery() {
<ExportModal
show={exportModalView}
onHide={closeExportModal}
- collectionNameMap={collectionNameMap}
+ collectionNameMap={state.allCollectionNameByID}
/>
<AuthenticateUserModal
open={authenticateUserModalView}
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index 3c03d98744..d679a26e9e 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -793,7 +793,7 @@ const deriveFavoriteFileIDs = (
/**
* Compute collection summaries from their dependencies.
*/
-export const deriveCollectionSummaries = (
+const deriveCollectionSummaries = (
user: User,
collections: Collection[],
files: EnteFile[],
@@ -847,7 +847,7 @@ const pseudoCollectionOptionsForFiles = (files: EnteFile[]) => ({
/**
* Compute hidden collection summaries from their dependencies.
*/
-export const deriveHiddenCollectionSummaries = (
+const deriveHiddenCollectionSummaries = (
user: User,
hiddenCollections: Collection[],
hiddenFiles: EnteFile[],
@@ -1079,11 +1079,11 @@ const derivePeopleView = (
people = filterTemp(people);
visiblePeople = filterTemp(visiblePeople);
}
- const findByID = (ps: Person[]) => ps.find((p) => p.id == selectedPersonID);
- let activePerson = findByID(visiblePeople);
+ const findByIDIn = (ps: Person[]) => ps.find((p) => p.id == selectedPersonID);
+ let activePerson = findByIDIn(visiblePeople);
if (!activePerson) {
// This might be one of the normally hidden small clusters.
- activePerson = findByID(people);
+ activePerson = findByIDIn(people);
if (activePerson) {
// Temporarily add this person's entry to the list of people
// surfaced in the people view.
@@ -1108,7 +1108,7 @@ const derivePeopleView = (
* function for recomputing filtered files whenever any bit of the underlying
* state that could affect the "albums" view changes (and we're showing it).
*/
-export const refreshingFilteredFilesIfShowingAlbums = (state: GalleryState) => {
+const refreshingFilteredFilesIfShowingAlbums = (state: GalleryState) => {
if (state.view?.type == "albums") {
const filteredFiles = deriveAlbumsFilteredFiles(
state.files,
@@ -1186,9 +1186,7 @@ const deriveAlbumsFilteredFiles = (
*
* See {@link refreshingFilteredFilesIfShowingAlbums} for more details.
*/
-export const refreshingFilteredFilesIfShowingHiddenAlbums = (
- state: GalleryState,
-) => {
+const refreshingFilteredFilesIfShowingHiddenAlbums = (state: GalleryState) => {
if (state.view?.type == "hidden-albums") {
const filteredFiles = deriveHiddenAlbumsFilteredFiles(
state.hiddenFiles,
@@ -1207,7 +1205,7 @@ export const refreshingFilteredFilesIfShowingHiddenAlbums = (
* "hidden-albums". This is useful if something that potentially affects both
* scenarios changes.
*/
-export const refreshingFilteredFilesIfShowingAlbumsOrHiddenAlbums = (
+const refreshingFilteredFilesIfShowingAlbumsOrHiddenAlbums = (
state: GalleryState,
) =>
refreshingFilteredFilesIfShowingHiddenAlbums(