🐛 Fix unable to repost

This commit is contained in:
LittleSheep 2024-12-07 23:40:26 +08:00
parent 2cbb7fb29e
commit 76cf08830b
7 changed files with 25 additions and 34 deletions

View File

@ -220,7 +220,7 @@ class PostWriteController extends ChangeNotifier {
if (reposting != null) { if (reposting != null) {
final post = await pt.getPost(reposting); final post = await pt.getPost(reposting);
replyingPost = post; repostingPost = post;
} }
} catch (err) { } catch (err) {
if (!context.mounted) return; if (!context.mounted) return;

View File

@ -7,7 +7,7 @@ import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/types/attachment.dart'; import 'package:surface/types/attachment.dart';
import 'package:surface/widgets/app_bar_leading.dart'; import 'package:surface/widgets/app_bar_leading.dart';
import 'package:surface/widgets/attachment/attachment_detail.dart'; import 'package:surface/widgets/attachment/attachment_zoom.dart';
import 'package:surface/widgets/attachment/attachment_item.dart'; import 'package:surface/widgets/attachment/attachment_item.dart';
import 'package:surface/widgets/dialog.dart'; import 'package:surface/widgets/dialog.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';

View File

@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:responsive_framework/responsive_framework.dart'; import 'package:responsive_framework/responsive_framework.dart';
import 'package:surface/types/attachment.dart'; import 'package:surface/types/attachment.dart';
import 'package:surface/widgets/attachment/attachment_detail.dart'; import 'package:surface/widgets/attachment/attachment_zoom.dart';
import 'package:surface/widgets/attachment/attachment_item.dart'; import 'package:surface/widgets/attachment/attachment_item.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';

View File

@ -16,6 +16,7 @@ import 'package:surface/widgets/post/post_media_pending_list.dart';
class ChatMessageInput extends StatefulWidget { class ChatMessageInput extends StatefulWidget {
final ChatMessageController controller; final ChatMessageController controller;
const ChatMessageInput({super.key, required this.controller}); const ChatMessageInput({super.key, required this.controller});
@override @override
@ -74,9 +75,7 @@ class ChatMessageInputState extends State<ChatMessageInput> {
media.name, media.name,
'interactive', 'interactive',
null, null,
mimetype: media.raw != null && media.type == PostWriteMediaType.image mimetype: media.raw != null && media.type == PostWriteMediaType.image ? 'image/png' : null,
? 'image/png'
: null,
); );
final item = await attach.chunkedUploadParts( final item = await attach.chunkedUploadParts(
@ -110,10 +109,7 @@ class ChatMessageInputState extends State<ChatMessageInput> {
widget.controller.sendMessage( widget.controller.sendMessage(
'messages.new', 'messages.new',
_contentController.text, _contentController.text,
attachments: _attachments attachments: _attachments.where((e) => e.attachment != null).map((e) => e.attachment!.rid).toList(),
.where((e) => e.attachment != null)
.map((e) => e.attachment!.rid)
.toList(),
relatedId: _editingMessage?.id, relatedId: _editingMessage?.id,
quoteId: _replyingMessage?.id, quoteId: _replyingMessage?.id,
editingMessage: _editingMessage, editingMessage: _editingMessage,
@ -167,15 +163,12 @@ class ChatMessageInputState extends State<ChatMessageInput> {
TweenAnimationBuilder<double>( TweenAnimationBuilder<double>(
tween: Tween(begin: 0, end: _progress), tween: Tween(begin: 0, end: _progress),
duration: Duration(milliseconds: 300), duration: Duration(milliseconds: 300),
builder: (context, value, _) => builder: (context, value, _) => LinearProgressIndicator(value: value, minHeight: 2),
LinearProgressIndicator(value: value, minHeight: 2),
) )
else if (_isBusy) else if (_isBusy)
const LinearProgressIndicator(value: null, minHeight: 2), const LinearProgressIndicator(value: null, minHeight: 2),
Padding( Padding(
padding: _attachments.isNotEmpty padding: _attachments.isNotEmpty ? const EdgeInsets.only(top: 8) : EdgeInsets.zero,
? const EdgeInsets.only(top: 8)
: EdgeInsets.zero,
child: PostMediaPendingList( child: PostMediaPendingList(
attachments: _attachments, attachments: _attachments,
isBusy: _isBusy, isBusy: _isBusy,
@ -187,18 +180,18 @@ class ChatMessageInputState extends State<ChatMessageInput> {
}, },
onUpdateBusy: (state) => setState(() => _isBusy = state), onUpdateBusy: (state) => setState(() => _isBusy = state),
), ),
).height(_attachments.isNotEmpty ? 80 + 8 : 0, animate: true).animate( )
const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), .height(_attachments.isNotEmpty ? 80 + 8 : 0, animate: true)
.animate(const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut),
SingleChildScrollView( SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
child: Padding( child: Padding(
padding: _replyingMessage != null padding: _replyingMessage != null ? const EdgeInsets.only(top: 8) : EdgeInsets.zero,
? const EdgeInsets.only(top: 8)
: EdgeInsets.zero,
child: _replyingMessage != null child: _replyingMessage != null
? MaterialBanner( ? MaterialBanner(
padding: const EdgeInsets.only(left: 16.0), padding: const EdgeInsets.only(left: 16.0),
leading: const Icon(Symbols.reply), leading: const Icon(Symbols.reply),
backgroundColor: Colors.transparent,
content: SingleChildScrollView( content: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
child: Column( child: Column(
@ -223,18 +216,18 @@ class ChatMessageInputState extends State<ChatMessageInput> {
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
), ),
).height(_replyingMessage != null ? 54 + 8 : 0, animate: true).animate( )
const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), .height(_replyingMessage != null ? 54 + 8 : 0, animate: true)
.animate(const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut),
SingleChildScrollView( SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
child: Padding( child: Padding(
padding: _editingMessage != null padding: _editingMessage != null ? const EdgeInsets.only(top: 8) : EdgeInsets.zero,
? const EdgeInsets.only(top: 8)
: EdgeInsets.zero,
child: _editingMessage != null child: _editingMessage != null
? MaterialBanner( ? MaterialBanner(
padding: const EdgeInsets.only(left: 16.0), padding: const EdgeInsets.only(left: 16.0),
leading: const Icon(Symbols.edit), leading: const Icon(Symbols.edit),
backgroundColor: Colors.transparent,
content: SingleChildScrollView( content: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
child: Column( child: Column(
@ -259,8 +252,9 @@ class ChatMessageInputState extends State<ChatMessageInput> {
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
), ),
).height(_editingMessage != null ? 54 + 8 : 0, animate: true).animate( )
const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut), .height(_editingMessage != null ? 54 + 8 : 0, animate: true)
.animate(const Duration(milliseconds: 300), Curves.fastEaseInToSlowEaseOut),
SizedBox( SizedBox(
height: 56, height: 56,
child: Row( child: Row(
@ -271,13 +265,10 @@ class ChatMessageInputState extends State<ChatMessageInput> {
controller: _contentController, controller: _contentController,
decoration: InputDecoration( decoration: InputDecoration(
isCollapsed: true, isCollapsed: true,
hintText: 'fieldChatMessage'.tr(args: [ hintText: 'fieldChatMessage'.tr(args: [widget.controller.channel?.name ?? 'loading'.tr()]),
widget.controller.channel?.name ?? 'loading'.tr()
]),
border: InputBorder.none, border: InputBorder.none,
), ),
onTapOutside: (_) => onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
FocusManager.instance.primaryFocus?.unfocus(),
onSubmitted: (_) { onSubmitted: (_) {
if (_isBusy) return; if (_isBusy) return;
_sendMessage(); _sendMessage();

View File

@ -15,7 +15,7 @@ import 'package:url_launcher/url_launcher_string.dart';
import 'package:path/path.dart'; import 'package:path/path.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'attachment/attachment_detail.dart'; import 'attachment/attachment_zoom.dart';
class MarkdownTextContent extends StatelessWidget { class MarkdownTextContent extends StatelessWidget {
final String content; final String content;

View File

@ -13,7 +13,7 @@ import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:surface/controllers/post_write_controller.dart'; import 'package:surface/controllers/post_write_controller.dart';
import 'package:surface/providers/sn_network.dart'; import 'package:surface/providers/sn_network.dart';
import 'package:surface/widgets/attachment/attachment_detail.dart'; import 'package:surface/widgets/attachment/attachment_zoom.dart';
import 'package:surface/widgets/dialog.dart'; import 'package:surface/widgets/dialog.dart';
class PostMediaPendingList extends StatelessWidget { class PostMediaPendingList extends StatelessWidget {