A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
// SPDX-License-Identifier: AGPL-3.0-or-later
import {GenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModal';
import {ExternalLink} from '@app/features/app/components/shared/ExternalLink';
import {SUPPORT_EMAIL, SUPPORT_EMAIL_MAILTO} from '@app/features/app/config/I18nDisplayConstants';
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
import {MULTIPART_ATTACHMENT_FALLBACK_MAX_REQUEST_SIZE} from '@app/features/messaging/utils/AttachmentUploadFallbackUtils';
import {formatFileSize} from '@app/features/messaging/utils/FileUtils';
import {msg, ph} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {observer} from 'mobx-react-lite';
const ATTACHMENT_UPLOAD_UNAVAILABLE_DESCRIPTOR = msg({
message: 'Attachment upload unavailable',
comment: 'Short label in the attachment upload connectivity modal. Keep it concise.',
});
export const AttachmentUploadConnectivityModal = observer(() => {
const {i18n} = useLingui();
const fallbackSizeFormatted = formatFileSize(i18n.locale, MULTIPART_ATTACHMENT_FALLBACK_MAX_REQUEST_SIZE);
return (
<GenericErrorModal
title={i18n._(ATTACHMENT_UPLOAD_UNAVAILABLE_DESCRIPTOR)}
message={
RuntimeConfig.isSelfHosted() ? (
<Trans>
We couldn't connect to the attachment upload service. {ph({PRODUCT_NAME: RuntimeConfig.productName})} can
fall back to the standard upload path for messages up to {fallbackSizeFormatted} total, but these
attachments exceed that combined limit and can't be sent until connectivity is restored. Try again later or
contact the administrators of this instance if this keeps happening.
</Trans>
) : (
<Trans>
We couldn't connect to the attachment upload service. {ph({PRODUCT_NAME: RuntimeConfig.productName})} can
fall back to the standard upload path for messages up to {fallbackSizeFormatted} total, but these
attachments exceed that combined limit and can't be sent until connectivity is restored. Try again later or
contact{' '}
<ExternalLink
href={SUPPORT_EMAIL_MAILTO}
data-flx="messaging.attachment-upload-connectivity-modal.external-link"
>
{SUPPORT_EMAIL}
</ExternalLink>{' '}
if this keeps happening.
</Trans>
)
}
data-flx="messaging.attachment-upload-connectivity-modal.confirm-modal"
/>
);
});