Skip to content

Commit d8ce836

Browse files
committed
fix(forum): 修复 ExpandEditor 回复错误(TFBUG 1&10)
1 parent aa8d91b commit d8ce836

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

lib/screens/forum_post_compose_screen.dart

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ class ForumPostComposeSheet extends StatefulWidget {
1212
final String forumId;
1313
final String? initialContent;
1414
final bool isReply;
15+
final String? postId;
1516

1617
const ForumPostComposeSheet({
1718
super.key,
1819
required this.forumId,
1920
this.initialContent,
2021
this.isReply = false,
22+
this.postId,
2123
});
2224
static Future<bool?> show(
2325
BuildContext context, {
2426
required String forumId,
2527
String? initialContent,
2628
bool isReply = false,
29+
String? postId,
2730
}) {
2831
return showDialog<bool>(
2932
context: context,
@@ -34,6 +37,7 @@ class ForumPostComposeSheet extends StatefulWidget {
3437
forumId: forumId,
3538
initialContent: initialContent,
3639
isReply: isReply,
40+
postId: postId,
3741
),
3842
);
3943
}
@@ -330,11 +334,24 @@ class _ForumPostComposeSheetState extends State<ForumPostComposeSheet> {
330334

331335
setState(() => _isSubmitting = true);
332336
try {
333-
final success = await TfApiClient.instance.sendPost(
334-
uid, password, fid,
335-
_titleController.text.trim(),
336-
_contentController.text.trim(),
337-
);
337+
final bool success;
338+
if (widget.isReply) {
339+
final pid = int.tryParse(widget.postId ?? '');
340+
if (pid == null) {
341+
Navigator.pop(context, false);
342+
return;
343+
}
344+
success = await TfApiClient.instance.addComment(
345+
uid, password, fid, pid,
346+
_contentController.text.trim(),
347+
);
348+
} else {
349+
success = await TfApiClient.instance.sendPost(
350+
uid, password, fid,
351+
_titleController.text.trim(),
352+
_contentController.text.trim(),
353+
);
354+
}
338355
if (!mounted) return;
339356
setState(() => _isSubmitting = false);
340357
if (success) {

lib/screens/forum_post_detail_screen.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,11 @@ class _ForumPostDetailScreenState extends State<ForumPostDetailScreen> {
470470
forumId: widget.forumId,
471471
initialContent: _commentController.text,
472472
isReply: true,
473+
postId: widget.postId,
473474
);
474475
if (result == true) {
475476
_commentController.clear();
477+
await _loadData();
476478
}
477479
}
478480

0 commit comments

Comments
 (0)