⬆️ Support some new server stuff
This commit is contained in:
@ -7,7 +7,7 @@ import 'package:solian/models/channel.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/chat.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/utils/service_url.dart';
|
||||
import 'package:solian/utils/services_url.dart';
|
||||
import 'package:solian/widgets/exts.dart';
|
||||
|
||||
class ChannelCallAction extends StatefulWidget {
|
||||
|
@ -5,7 +5,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:solian/models/channel.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/utils/service_url.dart';
|
||||
import 'package:solian/utils/services_url.dart';
|
||||
import 'package:solian/widgets/exts.dart';
|
||||
|
||||
class ChannelDeletion extends StatefulWidget {
|
||||
|
@ -10,19 +10,23 @@ class ChatMessageContent extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Markdown(
|
||||
data: item.content,
|
||||
shrinkWrap: true,
|
||||
selectable: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
onTapLink: (text, href, title) async {
|
||||
if (href == null) return;
|
||||
await launchUrlString(
|
||||
href,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
);
|
||||
if (item.type == 'm.text') {
|
||||
return Markdown(
|
||||
data: item.decodedContent['value'],
|
||||
shrinkWrap: true,
|
||||
selectable: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
onTapLink: (text, href, title) async {
|
||||
if (href == null) return;
|
||||
await launchUrlString(
|
||||
href,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:solian/models/message.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/utils/service_url.dart';
|
||||
import 'package:solian/utils/services_url.dart';
|
||||
import 'package:solian/widgets/exts.dart';
|
||||
|
||||
class ChatMessageDeletionDialog extends StatefulWidget {
|
||||
|
@ -9,7 +9,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:solian/models/message.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/utils/service_url.dart';
|
||||
import 'package:solian/utils/services_url.dart';
|
||||
import 'package:solian/widgets/exts.dart';
|
||||
import 'package:solian/widgets/posts/attachment_editor.dart';
|
||||
import 'package:badges/badges.dart' as badge;
|
||||
@ -55,6 +55,10 @@ class _ChatMessageEditorState extends State<ChatMessageEditor> {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> buildContentBody(String content, {String algorithm = 'plain'}) {
|
||||
return {'value': content, 'algorithm': algorithm};
|
||||
}
|
||||
|
||||
Future<void> sendMessage(BuildContext context) async {
|
||||
_focusNode.requestFocus();
|
||||
|
||||
@ -68,7 +72,8 @@ class _ChatMessageEditorState extends State<ChatMessageEditor> {
|
||||
final req = Request(widget.editing == null ? 'POST' : 'PUT', uri);
|
||||
req.headers['Content-Type'] = 'application/json';
|
||||
req.body = jsonEncode(<String, dynamic>{
|
||||
'content': _textController.value.text,
|
||||
'type': 'm.text',
|
||||
'content': buildContentBody(_textController.value.text),
|
||||
'attachments': _attachments,
|
||||
'reply_to': widget.replying?.id,
|
||||
});
|
||||
@ -106,7 +111,10 @@ class _ChatMessageEditorState extends State<ChatMessageEditor> {
|
||||
setState(() {
|
||||
_prevEditingId = widget.editing!.id;
|
||||
_attachments = widget.editing!.attachments ?? List.empty(growable: true);
|
||||
_textController.text = widget.editing!.content;
|
||||
|
||||
if (widget.editing!.type == 'm.text') {
|
||||
_textController.text = widget.editing!.decodedContent['value'];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user