Hoist state

This commit is contained in:
Manav Rathi 2024-04-24 09:22:17 +05:30
parent 0da46f3298
commit 0d0397124f
No known key found for this signature in database
4 changed files with 13 additions and 21 deletions

View file

@ -1,4 +1,3 @@
import log from "@/next/log";
import ChevronRight from "@mui/icons-material/ChevronRight";
import ScienceIcon from "@mui/icons-material/Science";
import { Box, DialogProps, Stack, Typography } from "@mui/material";
@ -37,13 +36,10 @@ export default function AdvancedSettings({ open, onClose, onRootClose }) {
}
};
const toggleCFProxy = async () => {
try {
appContext.setIsCFProxyDisabled(!appContext.isCFProxyDisabled);
} catch (e) {
log.error("toggleFasterUpload failed", e);
}
const toggleCFProxy = () => {
appContext.setIsCFProxyDisabled(!appContext.isCFProxyDisabled);
};
const [indexingStatus, setIndexingStatus] = useState<CLIPIndexingStatus>({
indexed: 0,
pending: 0,

View file

@ -275,21 +275,25 @@ class UploadManager {
private publicUploadProps: PublicUploadProps;
private uploaderName: string;
private uiService: UIService;
private isCFUploadProxyDisabled: boolean = false;
constructor() {
this.uiService = new UIService();
}
public async init(
progressUpdater: ProgressUpdater,
setFiles: SetFiles,
publicCollectProps: PublicUploadProps,
isCFUploadProxyDisabled: boolean,
) {
this.uiService = new UIService();
this.uiService.init(progressUpdater);
const remoteIsCFUploadProxyDisabled =
await getDisableCFUploadProxyFlag();
if (remoteIsCFUploadProxyDisabled) {
isCFUploadProxyDisabled = remoteIsCFUploadProxyDisabled;
}
UploadService.init(publicCollectProps, isCFUploadProxyDisabled);
this.isCFUploadProxyDisabled = isCFUploadProxyDisabled;
UploadService.init(publicCollectProps);
this.setFiles = setFiles;
this.publicUploadProps = publicCollectProps;
}
@ -597,6 +601,7 @@ class UploadManager {
fileWithCollection,
this.parsedMetadataJSONMap,
this.uploaderName,
this.isCFUploadProxyDisabled,
(
fileLocalID: number,
percentPerPart?: number,

View file

@ -70,14 +70,9 @@ class UploadService {
private uploadURLs: UploadURL[] = [];
private pendingUploadCount: number = 0;
private publicUploadProps: PublicUploadProps = undefined;
private isCFUploadProxyDisabled: boolean = false;
init(
publicUploadProps: PublicUploadProps,
isCFUploadProxyDisabled: boolean,
) {
init(publicUploadProps: PublicUploadProps) {
this.publicUploadProps = publicUploadProps;
this.isCFUploadProxyDisabled = isCFUploadProxyDisabled;
}
async setFileCount(fileCount: number) {
@ -85,10 +80,6 @@ class UploadService {
await this.preFetchUploadURLs();
}
getIsCFUploadProxyDisabled() {
return this.isCFUploadProxyDisabled;
}
reducePendingUploadCount() {
this.pendingUploadCount--;
}
@ -180,6 +171,7 @@ export const uploader = async (
fileWithCollection: FileWithCollection2,
parsedMetadataJSONMap: ParsedMetadataJSONMap,
uploaderName: string,
isCFUploadProxyDisabled: boolean,
makeProgessTracker: MakeProgressTracker,
): Promise<UploadResponse> => {
const name = assetName(fileWithCollection);
@ -268,7 +260,7 @@ export const uploader = async (
const backupedFile = await uploadToBucket(
encryptedFile.file,
makeProgessTracker,
uploadService.getIsCFUploadProxyDisabled(),
isCFUploadProxyDisabled,
);
const uploadedFile = await uploadService.uploadFile({

View file

@ -7,7 +7,6 @@ import { FILE_TYPE } from "constants/file";
import { Collection } from "types/collection";
import {
FilePublicMagicMetadata,
FilePublicMagicMetadataProps,
MetadataFileAttributes,
S3FileAttributes,
} from "types/file";