🐛 Fix compose sheet

This commit is contained in:
2025-10-31 19:15:22 +08:00
parent b3ef7d6ad0
commit b52eb95b14
3 changed files with 107 additions and 70 deletions

View File

@@ -22,6 +22,23 @@ class ComposeSubmitUtils {
throw Exception('Already submitting');
}
// Don't submit empty posts (no content and no attachments)
final hasContent =
state.titleController.text.trim().isNotEmpty ||
state.descriptionController.text.trim().isNotEmpty ||
state.contentController.text.trim().isNotEmpty;
final hasAttachments = state.attachments.value.isNotEmpty;
if (!hasContent && !hasAttachments) {
// Show error message if context is mounted
if (context.mounted) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('postContentEmpty')));
}
throw Exception('Post content is empty'); // Don't submit empty posts
}
try {
state.submitting.value = true;