59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
// Metro module 6187 (f6188).
|
|
import { AbortCodes, MAX_UPLOAD_COUNT } from "../../Constants";
|
|
import { getKestrelConfig, getEffectiveKestrelLimit } from "./experiments/KestrelExperiment";
|
|
import { maxFileSize } from "../../utils/FileUtils";
|
|
import showUploadFileSizeError from "./native/showUploadFileSizeError";
|
|
import AlertActionCreators from "../../actions/AlertActionCreators";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import { getAttachmentUploadAbortAlertContent } from "./getAttachmentUploadAbortAlert";
|
|
export function handleUploadMessageAttachmentsErrors({ file, guildId, analyticsLocations, code, reason }) {
|
|
if (code === void 0) {
|
|
return false;
|
|
}
|
|
if (code === AbortCodes.ENTITY_TOO_LARGE) {
|
|
const kestrelConfig = getKestrelConfig({
|
|
location: "native.handleUploadMessageAttachmentsErrors"
|
|
});
|
|
const baseMaxSize = maxFileSize(guildId);
|
|
showUploadFileSizeError({
|
|
file,
|
|
maxSize: getEffectiveKestrelLimit(kestrelConfig, baseMaxSize),
|
|
baseMaxSize,
|
|
guildId,
|
|
analyticsLocations,
|
|
errorReason: reason?.type
|
|
});
|
|
return true;
|
|
}
|
|
if (code === AbortCodes.TOO_MANY_ATTACHMENTS) {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.wOr6hB),
|
|
body: intl.formatToPlainString(t["qqyp/e"], {
|
|
limit: MAX_UPLOAD_COUNT
|
|
})
|
|
});
|
|
return true;
|
|
}
|
|
if (code === AbortCodes.ENTITY_EMPTY) {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.B3vFdU),
|
|
body: intl.string(t["9ZpT2C"])
|
|
});
|
|
return true;
|
|
}
|
|
if (code === AbortCodes.INVALID_FILE_ASSET) {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.B3vFdU),
|
|
body: intl.string(t.zMEjJg)
|
|
});
|
|
return true;
|
|
}
|
|
const attachmentUploadAbortAlertContent = getAttachmentUploadAbortAlertContent(code);
|
|
let r25 = attachmentUploadAbortAlertContent != null;
|
|
if (r25) {
|
|
AlertActionCreators.show(attachmentUploadAbortAlertContent);
|
|
r25 = true;
|
|
}
|
|
return r25;
|
|
}
|