This commit is contained in:
Manav Rathi 2024-11-27 16:37:21 +05:30
parent e912b876db
commit 33ed4a8dff
No known key found for this signature in database
3 changed files with 15 additions and 26 deletions

View File

@ -243,10 +243,9 @@ export default function PublicCollectionGallery() {
? await cryptoWorker.toB64(bs58.decode(ck))
: await cryptoWorker.fromHex(ck);
token.current = t;
downloadManager.setPublicAlbumsCredentials(
token.current,
undefined,
);
downloadManager.setPublicAlbumsCredentials({
accessToken: token.current,
});
await updateShouldDisableCFUploadProxy();
collectionKey.current = dck;
url.current = window.location.href;
@ -270,10 +269,10 @@ export default function PublicCollectionGallery() {
setPublicFiles(localPublicFiles);
passwordJWTToken.current =
await getLocalPublicCollectionPassword(collectionUID);
downloadManager.setPublicAlbumsCredentials(
token.current,
passwordJWTToken.current,
);
downloadManager.setPublicAlbumsCredentials({
accessToken: token.current,
accessTokenJWT: passwordJWTToken.current,
});
}
await syncWithRemote();
} finally {
@ -406,10 +405,10 @@ export default function PublicCollectionGallery() {
token.current,
);
passwordJWTToken.current = jwtToken;
downloadManager.setPublicAlbumsCredentials(
token.current,
passwordJWTToken.current,
);
downloadManager.setPublicAlbumsCredentials({
accessToken: token.current,
accessTokenJWT: passwordJWTToken.current,
});
const collectionUID = getPublicCollectionUID(token.current);
await savePublicCollectionPassword(collectionUID, jwtToken);
} catch (e) {

View File

@ -27,7 +27,7 @@ export const publicRequestHeaders = () => ({
/**
* A set of credentials needed to make public collections related API requests.
*/
interface PublicAlbumsCredentials {
export interface PublicAlbumsCredentials {
/**
* An access token that does the same job as the "X-Auth-Token" for usual
* authenticated API requests, except it will be passed as the

View File

@ -21,6 +21,7 @@ import {
import type { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import { type PublicAlbumsCredentials }from "@/base/http";
export interface LivePhotoSourceURL {
image: () => Promise<string | undefined>;
@ -145,14 +146,8 @@ class DownloadManager {
* Set the credentials that should be used for download files when we're
* running in the context of the public albums app.
*/
setPublicAlbumsCredentials(
token: string,
passwordToken: string | undefined,
) {
this.publicAlbumsCredentials = {
accessToken: token,
accessTokenJWT: passwordToken,
};
setPublicAlbumsCredentials(credentials: PublicAlbumsCredentials) {
this.publicAlbumsCredentials = credentials;
}
/**
@ -689,11 +684,6 @@ const photos_downloadFile = async (file: EnteFile): Promise<Response> => {
return retryEnsuringHTTPOk(getFile);
};
interface PublicAlbumsCredentials {
accessToken: string;
accessTokenJWT: string | undefined;
}
/**
* The various publicAlbums_* functions are used for the actual downloads when
* we're running in the context of the the public albums app.