π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Touch ups
Manav Rathi54aec6e0db54
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 0d2de6617b..0cc1434874 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -91,6 +91,9 @@ import { downloadSelectedFiles, getSelectedFiles } from "utils/file";import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";export default function PublicCollectionGallery() {+ const { showMiniDialog } = useBaseContext();+ const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();+const credentials = useRef<PublicAlbumsCredentials | undefined>(undefined);const collectionKey = useRef<string>(null);const url = useRef<string>(null);@@ -98,12 +101,10 @@ export default function PublicCollectionGallery() {const [publicFiles, setPublicFiles] = useState<EnteFile[]>(null);const [publicCollection, setPublicCollection] = useState<Collection>(null);const [errorMessage, setErrorMessage] = useState<string>(null);- const { showMiniDialog } = useBaseContext();- const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();const [loading, setLoading] = useState(true);+ const [isPasswordProtected, setIsPasswordProtected] = useState(false);+const router = useRouter();- const [isPasswordProtected, setIsPasswordProtected] =- useState<boolean>(false);const [photoListHeader, setPhotoListHeader] =useState<TimeStampListItem>(null);@@ -219,24 +220,22 @@ export default function PublicCollectionGallery() {}collectionKey.current = ck;url.current = window.location.href;- const localCollection = await savedPublicCollectionByKey(+ const collection = await savedPublicCollectionByKey(collectionKey.current,);const accessToken = t;let accessTokenJWT: string | undefined;- if (localCollection) {+ if (collection) {referralCode.current =await savedLastPublicCollectionReferralCode();- const sortAsc: boolean =- localCollection?.pubMagicMetadata?.data.asc ?? false;- setPublicCollection(localCollection);- const isPasswordProtected =- localCollection?.publicURLs?.[0]?.passwordEnabled;- setIsPasswordProtected(isPasswordProtected);- const localFiles =- await savedPublicCollectionFiles(accessToken);- const localPublicFiles = sortFiles(localFiles, sortAsc);- setPublicFiles(localPublicFiles);+ setPublicCollection(collection);+ const sortAsc =+ collection.pubMagicMetadata?.data.asc ?? false;+ setIsPasswordProtected(+ !!collection.publicURLs[0]?.passwordEnabled,+ );+ const files = await savedPublicCollectionFiles(accessToken);+ setPublicFiles(sortFiles(files, sortAsc));accessTokenJWT =await savedPublicCollectionAccessTokenJWT(accessToken);}diff --git a/web/packages/new/albums/services/public-collection.ts b/web/packages/new/albums/services/public-collection.tsindex 8d8a81ee76..d7d089b80b 100644--- a/web/packages/new/albums/services/public-collection.ts+++ b/web/packages/new/albums/services/public-collection.ts@@ -5,6 +5,7 @@ import {type PublicAlbumsCredentials,} from "ente-base/http";import { apiURL } from "ente-base/origins";+import { sortFiles } from "ente-gallery/utils/file";import {decryptRemoteCollection,RemoteCollection,@@ -157,11 +158,17 @@ const getPublicCollectionInfo = async (accessToken: string) => {** @param collection The public collection corresponding to the credentials.*+ * This function assumes that collection has already been pulled from remote and+ * is at its latest, remote, value. This assumption is used to skip fetching+ * files if the collection has not changed on remote (any updates to the files+ * will also increase the updation time of the collection that contains them).+ ** @param onSetFiles A callback that is invoked each time a new batch of updates* to the collection's files is fetched and processed. THe callback is called* the consolidated list of files after applying the updates received so far.*- * This callback can get called multiple times during the pull.+ * This callback can get called multiple times during the pull. The callback can+ * also never get called if no changes were pulled.*/export const pullPublicCollectionFiles = async (credentials: PublicAlbumsCredentials,@@ -169,12 +176,14 @@ export const pullPublicCollectionFiles = async (onSetFiles: (files: EnteFile[]) => void,) => {const { accessToken } = credentials;+ const sortAsc = collection.pubMagicMetadata?.data.asc ?? false;++ let sinceTime = (await savedPublicCollectionLastSyncTime(accessToken)) ?? 0;+ if (sinceTime == collection.updationTime) return;const files = await savedPublicCollectionFiles(accessToken);const filesByID = new Map(files.map((f) => [f.id, f]));- let sinceTime = (await savedPublicCollectionLastSyncTime(accessToken)) ?? 0;-while (true) {const { diff, hasMore } = await getPublicCollectionDiff(credentials,@@ -193,7 +202,7 @@ export const pullPublicCollectionFiles = async (}}- const files = [...filesByID.values()];+ const files = sortFiles([...filesByID.values()], sortAsc);await savePublicCollectionFiles(accessToken, files);await savePublicCollectionLastSyncTime(accessToken, sinceTime);onSetFiles(files);