♿ Block user action when attachments isn't ready
This commit is contained in:
parent
8b3c45ab29
commit
27c60fc8cb
@ -8,6 +8,7 @@ import 'package:solian/controllers/post_editor_controller.dart';
|
|||||||
import 'package:solian/exts.dart';
|
import 'package:solian/exts.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/models/realm.dart';
|
import 'package:solian/models/realm.dart';
|
||||||
|
import 'package:solian/providers/attachment_uploader.dart';
|
||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
@ -56,6 +57,14 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
if (auth.isAuthorized.isFalse) return;
|
if (auth.isAuthorized.isFalse) return;
|
||||||
if (_editorController.isEmpty) return;
|
if (_editorController.isEmpty) return;
|
||||||
|
|
||||||
|
final AttachmentUploaderController uploader = Get.find();
|
||||||
|
if (uploader.queueOfUpload.any(
|
||||||
|
((x) => x.usage == 'i.attachment' && x.isUploading),
|
||||||
|
)) {
|
||||||
|
context.showErrorDialog('attachmentUploadInProgress'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() => _isBusy = true);
|
setState(() => _isBusy = true);
|
||||||
|
|
||||||
final client = auth.configureClient('interactive');
|
final client = auth.configureClient('interactive');
|
||||||
@ -92,15 +101,16 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelAction() {
|
void _cancelAction() {
|
||||||
_editorController.localClear();
|
_editorController.localClear();
|
||||||
AppRouter.instance.pop();
|
AppRouter.instance.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
Post? get _editTo => _editorController.editTo.value;
|
Post? get _editTo => _editorController.editTo.value;
|
||||||
|
|
||||||
Post? get _replyTo => _editorController.replyTo.value;
|
Post? get _replyTo => _editorController.replyTo.value;
|
||||||
|
|
||||||
Post? get _repostTo => _editorController.repostTo.value;
|
Post? get _repostTo => _editorController.repostTo.value;
|
||||||
Realm? get _realm => _editorController.realmZone.value;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -114,7 +124,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final notifyBannerActions = [
|
final notifyBannerActions = [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: cancelAction,
|
onPressed: _cancelAction,
|
||||||
child: Text('cancel'.tr),
|
child: Text('cancel'.tr),
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
abstract class ServiceFinder {
|
abstract class ServiceFinder {
|
||||||
static const bool devFlag = false;
|
static const bool devFlag = true;
|
||||||
|
|
||||||
static const String dealerUrl =
|
static const String dealerUrl =
|
||||||
devFlag ? 'http://localhost:8442' : 'https://api.sn.solsynth.dev';
|
devFlag ? 'http://localhost:8442' : 'https://api.sn.solsynth.dev';
|
||||||
|
@ -160,6 +160,7 @@ const i18nEnglish = {
|
|||||||
'attachmentAutoUpload': 'Auto Upload',
|
'attachmentAutoUpload': 'Auto Upload',
|
||||||
'attachmentUploadQueue': 'Upload Queue',
|
'attachmentUploadQueue': 'Upload Queue',
|
||||||
'attachmentUploadQueueStart': 'Start All',
|
'attachmentUploadQueueStart': 'Start All',
|
||||||
|
'attachmentUploadInProgress': 'There are attachments being uploaded. Please wait until all attachments have been uploaded before proceeding...',
|
||||||
'attachmentAttached': 'Exists Files',
|
'attachmentAttached': 'Exists Files',
|
||||||
'attachmentUploadBlocked': 'Upload blocked, there is currently a task in progress...',
|
'attachmentUploadBlocked': 'Upload blocked, there is currently a task in progress...',
|
||||||
'attachmentAdd': 'Attach attachments',
|
'attachmentAdd': 'Attach attachments',
|
||||||
|
@ -149,6 +149,7 @@ const i18nSimplifiedChinese = {
|
|||||||
'attachmentAutoUpload': '自动上传',
|
'attachmentAutoUpload': '自动上传',
|
||||||
'attachmentUploadQueue': '上传队列',
|
'attachmentUploadQueue': '上传队列',
|
||||||
'attachmentUploadQueueStart': '整队上传',
|
'attachmentUploadQueueStart': '整队上传',
|
||||||
|
'attachmentUploadInProgress': '有附件正在上传,请等待所有附件上传完毕后再进行操作……',
|
||||||
'attachmentAttached': '已附附件',
|
'attachmentAttached': '已附附件',
|
||||||
'attachmentUploadBlocked': '上传受阻,当前已有任务进行中……',
|
'attachmentUploadBlocked': '上传受阻,当前已有任务进行中……',
|
||||||
'attachmentAdd': '附加附件',
|
'attachmentAdd': '附加附件',
|
||||||
|
@ -455,11 +455,12 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (_uploadController.isUploading.value) {
|
if (_uploadController.isUploading.value) {
|
||||||
return const SizedBox(
|
return SizedBox(
|
||||||
width: 18,
|
width: 18,
|
||||||
height: 18,
|
height: 18,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2.5,
|
strokeWidth: 2.5,
|
||||||
|
value: _uploadController.progressOfUpload.value,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@ import 'package:solian/exts.dart';
|
|||||||
import 'package:solian/models/account.dart';
|
import 'package:solian/models/account.dart';
|
||||||
import 'package:solian/models/channel.dart';
|
import 'package:solian/models/channel.dart';
|
||||||
import 'package:solian/models/event.dart';
|
import 'package:solian/models/event.dart';
|
||||||
|
import 'package:solian/providers/attachment_uploader.dart';
|
||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/widgets/attachments/attachment_editor.dart';
|
import 'package:solian/widgets/attachments/attachment_editor.dart';
|
||||||
import 'package:solian/widgets/chat/chat_event.dart';
|
import 'package:solian/widgets/chat/chat_event.dart';
|
||||||
|
import 'package:badges/badges.dart' as badges;
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class ChatMessageInput extends StatefulWidget {
|
class ChatMessageInput extends StatefulWidget {
|
||||||
@ -80,6 +82,14 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
final prof = auth.userProfile.value!;
|
final prof = auth.userProfile.value!;
|
||||||
if (auth.isAuthorized.isFalse) return;
|
if (auth.isAuthorized.isFalse) return;
|
||||||
|
|
||||||
|
final AttachmentUploaderController uploader = Get.find();
|
||||||
|
if (uploader.queueOfUpload.any(
|
||||||
|
((x) => x.usage == 'm.attachment' && x.isUploading),
|
||||||
|
)) {
|
||||||
|
context.showErrorDialog('attachmentUploadInProgress'.tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Response resp;
|
Response resp;
|
||||||
|
|
||||||
final mentionedUserNames = _findMentionedUsers(_textController.text);
|
final mentionedUserNames = _findMentionedUsers(_textController.text);
|
||||||
@ -259,7 +269,18 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.attach_file),
|
icon: badges.Badge(
|
||||||
|
badgeContent: Text(
|
||||||
|
_attachments.length.toString(),
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
showBadge: _attachments.isNotEmpty,
|
||||||
|
position: badges.BadgePosition.topEnd(
|
||||||
|
top: -12,
|
||||||
|
end: -8,
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.file_present_rounded),
|
||||||
|
),
|
||||||
color: Colors.teal,
|
color: Colors.teal,
|
||||||
onPressed: () => _editAttachments(),
|
onPressed: () => _editAttachments(),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user