Check for no media descriptions when posting & boosting

This commit is contained in:
Lim Chee Aun 2023-03-14 20:42:37 +08:00
parent 10090e316a
commit a838e30f4a
2 changed files with 20 additions and 1 deletions

View file

@ -699,6 +699,17 @@ function Compose({
}
// TODO: check for URLs and use `charactersReservedPerUrl` to calculate max characters
if (mediaAttachments.length > 0) {
// If there are media attachments, check if they have no descriptions
const noDescription = mediaAttachments.some(
(media) => !media.description?.trim(),
);
if (noDescription) {
const yes = confirm('Some media have no descriptions. Continue?');
if (!yes) return;
}
}
// Post-cleanup
spoilerText = (sensitive && spoilerText) || undefined;
status = status === '' ? undefined : status;

View file

@ -271,7 +271,15 @@ function Status({
}
try {
if (!reblogged) {
const yes = confirm('Boost this post?');
// Check if media has no descriptions
const hasNoDescriptions = mediaAttachments.some(
(attachment) => !attachment.description?.trim?.(),
);
let confirmText = 'Boost this post?';
if (hasNoDescriptions) {
confirmText += '\n\n⚠ Some media have no descriptions.';
}
const yes = confirm(confirmText);
if (!yes) {
return;
}