Files
discord-decomp/lib/uploader/Upload.tsx
T
2026-11-01 12:12:55 +02:00

74 lines
1.9 KiB
TypeScript

// Metro module 4722 (f4723).
import { EventEmitter } from "../../_bundle/EventEmitter_652";
import { getFile } from "../../utils/UploadUtils";
import Module12 from "../../_bundle/Module12";
import { classifyFile } from "../../utils/FileUtils";
import { v4 } from "../../_bundle/Module514";
let c2880_4 = {
REACT_NATIVE: 0,
0: "REACT_NATIVE",
WEB: 1,
1: "WEB"
};
const r20 = {
FILE_ATTACHMENT: 0,
0: "FILE_ATTACHMENT",
IMAGE_PICKER: 1,
1: "IMAGE_PICKER",
IMAGE_EDITOR: 2,
2: "IMAGE_EDITOR"
};
class Upload extends EventEmitter {
allowOptimization = true;
constructor(a0) {
super();
this.item = a0;
if (a0.platform === c2880_4.REACT_NATIVE) {
let id2 = a0.id;
if (id2 == null) {
id2 = a0.uri;
}
this.id = id2;
const file = getFile({
uri: a0.uri,
overrideFilename: a0.filename,
overrideType: a0.mimeType
});
this.filename = file.filename;
this.isImage = file.isImage;
this.isVideo = file.isVideo;
this.mimeType = file.type;
this.origin = a0.origin;
this.durationSecs = a0.durationSecs;
this.waveform = a0.waveform;
} else {
let id = a0.id;
if (id == null) {
id = Module12.uniqueId("upload");
}
this.id = id;
this.classification = classifyFile(a0.file);
this.isImage = this.classification === "image";
this.isVideo = this.classification === "video";
this.filename = a0.file.name;
this.mimeType = a0.file.type;
this.origin = a0.origin;
}
this.isThumbnail = a0.isThumbnail;
this.clip = a0.clip;
this.uniqueId = v4();
this.spoiler = false;
this.description = null;
}
cancel() {}
resetState() {
return this;
}
}
export default Upload;
export { c2880_4 as UploadPlatform };
export function isResolvedUpload(a0) {
return a0.isVideo !== void 0 && a0.isImage !== void 0;
}
export { r20 as UploadOrigin };