Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Can\'t find an app able to open this media."),
"errorUnknownWithCode": m21,
"errorUnknownWithMessage": m22,
"errorUploadAttachmentFailed": MessageLookupByLibrary.simpleMessage(
"Failed to upload message attachment"),
"errorUsedPhone": MessageLookupByLibrary.simpleMessage(
"ERROR 20122: This phone number is already associated with another account."),
"errorUserInvalidFormat":
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("无法找到能打开该媒体的应用"),
"errorUnknownWithCode": m21,
"errorUnknownWithMessage": m22,
"errorUploadAttachmentFailed":
MessageLookupByLibrary.simpleMessage("消息附件上传失败"),
"errorUsedPhone":
MessageLookupByLibrary.simpleMessage("错误 20122:电话号码已经被占用。"),
"errorUserInvalidFormat":
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"errorUnableToOpenMedia" : "Can't find an app able to open this media.",
"errorUnknownWithCode" : "ERROR: {arg0}",
"errorUnknownWithMessage" : "ERROR: {arg0}",
"errorUploadAttachmentFailed" : "Failed to upload message attachment",
"errorUsedPhone" : "ERROR 20122: This phone number is already associated with another account.",
"errorUserInvalidFormat" : "Invalid user id",
"errorWithdrawalMemoFormatIncorrect" : "ERROR 20131: Withdrawal memo format incorrect.",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"errorUnableToOpenMedia" : "无法找到能打开该媒体的应用",
"errorUnknownWithCode" : "错误:{arg0}",
"errorUnknownWithMessage" : "错误:{arg0}",
"errorUploadAttachmentFailed" : "消息附件上传失败",
"errorUsedPhone" : "错误 20122:电话号码已经被占用。",
"errorUserInvalidFormat" : "用户数据不合法",
"errorWithdrawalMemoFormatIncorrect" : "错误 20131:提现备注格式不正确",
Expand Down
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:isolate/isolate.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:path/path.dart' as p;
import 'package:protocol_handler/protocol_handler.dart';
import 'package:quick_breakpad/quick_breakpad.dart';
Expand Down Expand Up @@ -82,7 +83,7 @@ Future<void> main(List<String> args) async {
};

HydratedBlocOverrides.runZoned(
() => runApp(const App()),
() => runApp(const OverlaySupport.global(child: App())),
blocObserver: kDebugMode ? CustomBlocObserver() : null,
storage: storage,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/home/bloc/conversation_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ class ConversationCubit extends SimpleCubit<ConversationState?>
await _conversationItem(context, conversationId);

if (_conversation == null && sync) {
showToastLoading(context);
showToastLoading();
await context.accountServer.refreshConversation(conversationId);
_conversation = await _conversationItem(context, conversationId);
}

hasUnreadMessage ??= (_conversation?.unseenMessageCount ?? 0) > 0;

if (_conversation == null) {
return showToastFailed(context, null);
return showToastFailed(null);
}

final _initIndexMessageId = initIndexMessageId ??
Expand Down Expand Up @@ -313,7 +313,7 @@ class ConversationCubit extends SimpleCubit<ConversationState?>
user ?? await database.userDao.userById(userId).getSingleOrNull();

if (_user == null) {
return showToastFailed(context, ToastError(context.l10n.userNotFound));
return showToastFailed(ToastError(context.l10n.userNotFound));
}

final app = await database.appDao.findAppById(userId);
Expand Down
4 changes: 0 additions & 4 deletions lib/ui/home/chat/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,6 @@ class _ConversationHandle extends ConversationMenuHandle {
}
final isGroupConversation = conversationState.isGroup == true;
await runFutureWithToast(
context,
context.accountServer.muteConversation(
result,
conversationId: isGroupConversation ? conversationId : null,
Expand All @@ -1182,7 +1181,6 @@ class _ConversationHandle extends ConversationMenuHandle {
@override
void pin() {
runFutureWithToast(
context,
context.accountServer.pin(conversationId),
);
}
Expand All @@ -1206,7 +1204,6 @@ class _ConversationHandle extends ConversationMenuHandle {
@override
void unPin() {
runFutureWithToast(
context,
context.accountServer.unpin(conversationId),
);
}
Expand All @@ -1219,7 +1216,6 @@ class _ConversationHandle extends ConversationMenuHandle {
}
final isGroup = conversationState.isGroup == true;
runFutureWithToast(
context,
context.accountServer.unMuteConversation(
conversationId: isGroup ? conversationId : null,
userId: isGroup ? null : conversationState.conversation?.ownerId,
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/home/chat/image_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1500,11 +1500,11 @@ class _NormalOperationBar extends HookWidget {
),
TextButton(
onPressed: () async {
showToastLoading(context);
showToastLoading();
final snapshot =
await context.read<_ImageEditorBloc>().takeSnapshot();
if (snapshot == null) {
await showToastFailed(context, null);
showToastFailed(null);
return;
}
Toast.dismiss();
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/home/chat/input_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class _AnimatedSendOrVoiceButton extends HookWidget {
}

void showMaxLengthReachedToast(BuildContext context) =>
showToastFailed(context, ToastError(context.l10n.contentTooLong));
showToastFailed(ToastError(context.l10n.contentTooLong));

void _sendPostMessage(
BuildContext context, TextEditingController textEditingController) {
Expand Down
5 changes: 2 additions & 3 deletions lib/ui/home/chat/selection_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class SelectionBottomBar extends HookWidget {
final messageIds = cubit.state.selectedMessageIds;

await runWithLoading(
context,
() => context.accountServer.sendTranscriptMessage(
messageIds.toList(),
result.first.encryptCategory!,
Expand All @@ -68,7 +67,7 @@ class SelectionBottomBar extends HookWidget {
final cubit = context.read<MessageSelectionCubit>();
final messageIds = cubit.state.selectedMessageIds;

await runWithLoading(context, () async {
await runWithLoading(() async {
for (final id in messageIds) {
await context.accountServer.forwardMessage(
id,
Expand Down Expand Up @@ -98,7 +97,7 @@ class SelectionBottomBar extends HookWidget {
return;
}
d('messagesToDelete: $messagesToDelete');
await runWithLoading(context, () async {
await runWithLoading(() async {
for (final id in messagesToDelete) {
await context.accountServer.deleteMessage(id);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/home/chat/voice_recorder_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ class VoiceRecorderBottomBar extends HookWidget {
final audioFile = File(recordedResult.path);
if (!audioFile.existsSync()) {
e('audio file does not exist.');
showToastFailed(context, null);
showToastFailed(null);
return;
}
if (audioFile.lengthSync() == 0) {
e('audio file is empty.');
showToastFailed(context, null);
showToastFailed(null);
return;
}
}, [recordedResult]);
Expand Down
48 changes: 17 additions & 31 deletions lib/ui/home/chat_slide_page/chat_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,13 @@ class ChatInfoPage extends HookWidget {
if (result == null || result.isEmpty) return;
final conversationId = result.first.conversationId;

await runFutureWithToast(
context,
accountServer.sendContactMessage(
conversation.userId!,
conversation.name,
result.first.encryptCategory!,
conversationId: conversationId,
recipientId: result.first.userId,
));
await runFutureWithToast(accountServer.sendContactMessage(
conversation.userId!,
conversation.name,
result.first.encryptCategory!,
conversationId: conversationId,
recipientId: result.first.userId,
));
},
),
),
Expand Down Expand Up @@ -222,7 +220,6 @@ class ChatInfoPage extends HookWidget {
if (result == null) return;

await runFutureWithToast(
context,
context.accountServer.editGroup(
conversationId,
announcement: result,
Expand Down Expand Up @@ -256,7 +253,6 @@ class ChatInfoPage extends HookWidget {
onTap: () async {
if (muting) {
await runFutureWithToast(
context,
context.accountServer.unMuteConversation(
conversationId:
isGroupConversation ? conversationId : null,
Expand All @@ -273,15 +269,13 @@ class ChatInfoPage extends HookWidget {
if (result == null) return;

await runFutureWithToast(
context,
context.accountServer.muteConversation(
result,
conversationId:
isGroupConversation ? conversationId : null,
userId: isGroupConversation
? null
: conversation.userId,
));
result,
conversationId:
isGroupConversation ? conversationId : null,
userId:
isGroupConversation ? null : conversation.userId,
));
},
),
if (!isGroupConversation ||
Expand All @@ -302,7 +296,6 @@ class ChatInfoPage extends HookWidget {
if (name?.isEmpty ?? true) return;

await runFutureWithToast(
context,
isGroupConversation
? accountServer.editGroup(
conversation.conversationId,
Expand Down Expand Up @@ -359,7 +352,6 @@ class ChatInfoPage extends HookWidget {
if (!result) return;

await runFutureWithToast(
context,
accountServer.unblockUser(conversation.userId!),
);
},
Expand All @@ -381,7 +373,6 @@ class ChatInfoPage extends HookWidget {
if (!result) return;

await runFutureWithToast(
context,
accountServer.removeUser(conversation.userId!),
);
},
Expand All @@ -400,7 +391,6 @@ class ChatInfoPage extends HookWidget {
if (!result) return;

await runFutureWithToast(
context,
accountServer.blockUser(conversation.userId!),
);
},
Expand Down Expand Up @@ -435,7 +425,6 @@ class ChatInfoPage extends HookWidget {
if (!result) return;

await runFutureWithToast(
context,
accountServer.exitGroup(conversationId),
);

Expand Down Expand Up @@ -491,7 +480,6 @@ class ChatInfoPage extends HookWidget {
if (userId == null) return;

await runFutureWithToast(
context,
accountServer.report(userId),
);
},
Expand Down Expand Up @@ -581,12 +569,10 @@ class _AddToContactsButton extends StatelessWidget {
'ContactsAdd: username should not be null.');
assert(conversation.isGroup != true,
'ContactsAdd conversation should not be a group.');
runFutureWithToast(
context,
context.accountServer.addUser(
conversation.userId!,
username,
));
runFutureWithToast(context.accountServer.addUser(
conversation.userId!,
username,
));
},
child: Text(
conversation.isBot!
Expand Down
3 changes: 0 additions & 3 deletions lib/ui/home/chat_slide_page/circle_manager_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class CircleManagerPage extends HookWidget {
);

await runFutureWithToast(
context,
context.accountServer.createCircle(name!, [
CircleConversationRequest(
action: CircleConversationAction.add,
Expand Down Expand Up @@ -138,15 +137,13 @@ class _CircleManagerItem extends StatelessWidget {

if (selected) {
await runFutureWithToast(
context,
context.accountServer.circleRemoveConversation(
circleId, conversation!.conversationId),
);
return;
}

await runFutureWithToast(
context,
context.accountServer.editCircleConversation(
circleId,
[
Expand Down
7 changes: 3 additions & 4 deletions lib/ui/home/chat_slide_page/disappear_message_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Future<void> _updateConversationExpireDuration(
);
} catch (error, stackTrace) {
e('update conversation expire duration failed $error $stackTrace');
await showToastFailed(context, error);
showToastFailed(error);
}
}

Expand Down Expand Up @@ -330,8 +330,7 @@ class _CustomExpireTimeDialog extends HookWidget {
return;
}
if (value > unit.value.maxValue) {
await showToastFailed(
context,
showToastFailed(
ToastError(context.l10n.disappearingCustomTimeMaxWarning(
unit.value
.toDuration(unit.value.maxValue)
Expand All @@ -340,7 +339,7 @@ class _CustomExpireTimeDialog extends HookWidget {
);
return;
}
showToastLoading(context);
showToastLoading();
await _updateConversationExpireDuration(context,
duration: duration, conversationId: conversationId);
Toast.dismiss();
Expand Down
Loading