修复语音房列表的bug
This commit is contained in:
parent
575a252f90
commit
60d5c427de
@ -16,8 +16,8 @@ class SCVariant1Config implements AppConfig {
|
||||
@override
|
||||
String get apiHost => const String.fromEnvironment(
|
||||
'API_HOST',
|
||||
defaultValue: 'http://10.0.2.2:1100/',
|
||||
); // 默认走模拟器宿主机地址,真机可通过 --dart-define=API_HOST 覆盖
|
||||
defaultValue: 'https://jvapi.haiyihy.com/',
|
||||
); // 默认连线上环境,本地调试可通过 --dart-define=API_HOST 覆盖
|
||||
|
||||
@override
|
||||
String get imgHost => 'https://img.atuchat.com/'; // 测试图片服务器,上架前需替换为正式域名
|
||||
@ -74,7 +74,7 @@ class SCVariant1Config implements AppConfig {
|
||||
int get primaryColor => 0xffFF5722; // 不同主色(橙色)
|
||||
|
||||
@override
|
||||
String get tencentImAppid => '20035299';
|
||||
String get tencentImAppid => '20036101';
|
||||
|
||||
@override
|
||||
String get agoraRtcAppid => 'ceb9e2620d454bca9725f7a7f11d4019';
|
||||
@ -86,7 +86,7 @@ class SCVariant1Config implements AppConfig {
|
||||
String get gameAppChannel => 'yumi';
|
||||
|
||||
@override
|
||||
String get bigBroadcastGroup => '@TGS#2XDMSPK5CR';
|
||||
String get bigBroadcastGroup => '@TGS#2RUK4PK5C2';
|
||||
|
||||
@override
|
||||
String get imAdmin => 'c2c_yumiadmin';
|
||||
|
||||
@ -16,6 +16,9 @@ import 'package:yumi/shared/tools/sc_loading_manager.dart';
|
||||
import 'package:yumi/shared/tools/sc_version_utils.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:yumi/services/audio/rtc_manager.dart';
|
||||
import 'package:yumi/services/audio/rtm_manager.dart';
|
||||
|
||||
///密码账户登录
|
||||
class SCLoginWithAccountPage extends StatefulWidget {
|
||||
@ -365,6 +368,18 @@ class SCLoginWithAccountPageState extends State<SCLoginWithAccountPage>
|
||||
SCVersionUtils.checkReview(),
|
||||
]);
|
||||
var user = (results[0] as SocialChatLoginRes);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
await Provider.of<RtcProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).resetLocalRoomState(
|
||||
fallbackRtmProvider: Provider.of<RtmProvider>(context, listen: false),
|
||||
);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
AccountStorage().setCurrentUser(user);
|
||||
SCLoadingManager.hide();
|
||||
DataPersistence.setString("Login_Account", account);
|
||||
|
||||
@ -21,6 +21,8 @@ import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||
import 'package:yumi/services/general/sc_app_general_manager.dart';
|
||||
import 'package:yumi/services/auth/user_profile_manager.dart';
|
||||
import 'package:yumi/services/audio/rtc_manager.dart';
|
||||
import 'package:yumi/services/audio/rtm_manager.dart';
|
||||
import 'package:yumi/app/constants/sc_global_config.dart';
|
||||
|
||||
import '../../../shared/business_logic/usecases/sc_custom_filtering_textinput_formatter.dart';
|
||||
@ -542,6 +544,15 @@ class _SCEditProfilePageState extends State<SCEditProfilePage> {
|
||||
idToken,
|
||||
userProvider!.editUser!,
|
||||
);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
await Provider.of<RtcProvider>(context, listen: false).resetLocalRoomState(
|
||||
fallbackRtmProvider: Provider.of<RtmProvider>(context, listen: false),
|
||||
);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
AccountStorage().setCurrentUser(user);
|
||||
SCLoadingManager.hide();
|
||||
SCNavigatorUtils.push(context, SCRoutes.home, clearStack: true);
|
||||
|
||||
@ -41,12 +41,16 @@ class _SplashPageState extends State<SplashPage> {
|
||||
if (startPages.length > 1) {
|
||||
int index = Random().nextInt(startPages.length);
|
||||
currentStartPage = result[index];
|
||||
} else {
|
||||
} else if (startPages.isNotEmpty) {
|
||||
currentStartPage = result.first;
|
||||
} else {
|
||||
currentStartPage = null;
|
||||
}
|
||||
|
||||
status = 1;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import 'package:yumi/shared/tools/sc_lk_dialog_util.dart';
|
||||
import 'package:yumi/shared/tools/sc_loading_manager.dart';
|
||||
import 'package:yumi/shared/tools/sc_gift_vap_svga_manager.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/local/data_persistence.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/join_room_res.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/mic_res.dart';
|
||||
@ -290,7 +291,15 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
}
|
||||
if (roomId == currenRoom?.roomProfile?.roomProfile?.id) {
|
||||
///最小化进入房间,或者进入的是同一个房间
|
||||
loadRoomInfo(currenRoom?.roomProfile?.roomProfile?.id ?? "");
|
||||
final loaded = await loadRoomInfo(
|
||||
currenRoom?.roomProfile?.roomProfile?.id ?? "",
|
||||
);
|
||||
if (!loaded) {
|
||||
return;
|
||||
}
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
Provider.of<SocialChatUserProfileManager>(
|
||||
context,
|
||||
listen: false,
|
||||
@ -321,8 +330,12 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
if (currenRoom != null) {
|
||||
await exitCurrentVoiceRoomSession(false);
|
||||
}
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
rtmProvider = Provider.of<RtmProvider>(context, listen: false);
|
||||
SCLoadingManager.show(context: context);
|
||||
try {
|
||||
currenRoom = await SCAccountRepository().entryRoom(
|
||||
roomId,
|
||||
pwd: pwd,
|
||||
@ -333,8 +346,13 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
needOpenRedenvelope: needOpenRedenvelope,
|
||||
redPackId: redPackId,
|
||||
);
|
||||
SCLoadingManager.hide();
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
await resetLocalRoomState(fallbackRtmProvider: rtmProvider);
|
||||
rethrow;
|
||||
} finally {
|
||||
SCLoadingManager.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,6 +569,28 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> resetLocalRoomState({RtmProvider? fallbackRtmProvider}) async {
|
||||
rtmProvider ??= fallbackRtmProvider;
|
||||
try {
|
||||
SCHeartbeatUtils.cancelTimer();
|
||||
SCHeartbeatUtils.cancelAnchorTimer();
|
||||
final groupId = currenRoom?.roomProfile?.roomProfile?.roomAccount ?? "";
|
||||
if (groupId.isNotEmpty) {
|
||||
await rtmProvider?.quitGroup(groupId);
|
||||
}
|
||||
await engine?.leaveChannel();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
await engine?.release();
|
||||
} catch (e) {
|
||||
print('rtc清理本地房间状态出错: $e');
|
||||
} finally {
|
||||
engine = null;
|
||||
rtmProvider?.cleanRoomData();
|
||||
_clearData();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
///清空列表数据
|
||||
void _clearData() {
|
||||
roomRocketStatus = null;
|
||||
@ -568,6 +608,7 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
currenRoom = null;
|
||||
isMic = true;
|
||||
isMusicPlaying = false;
|
||||
DataPersistence.setLastTimeRoomId("");
|
||||
SCGiftVapSvgaManager().clearTasks();
|
||||
SCRoomUtils.closeAllDialogs();
|
||||
SCGlobalConfig.isEntryVehicleAnimation = true;
|
||||
@ -853,8 +894,9 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void loadRoomInfo(String roomId) {
|
||||
SCChatRoomRepository().specific(roomId).then((value) {
|
||||
Future<bool> loadRoomInfo(String roomId) async {
|
||||
try {
|
||||
final value = await SCChatRoomRepository().specific(roomId);
|
||||
currenRoom = currenRoom?.copyWith(
|
||||
roomProfile: currenRoom?.roomProfile?.copyWith(
|
||||
roomCounter: value.counter,
|
||||
@ -879,7 +921,12 @@ class RealTimeCommunicationManager extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
await resetLocalRoomState(fallbackRtmProvider: rtmProvider);
|
||||
SCTts.show("Room not exists");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
///解锁麦位
|
||||
|
||||
@ -12,6 +12,9 @@ import 'package:yumi/shared/data_sources/sources/local/user_manager.dart';
|
||||
import 'package:yumi/shared/data_sources/sources/repositories/sc_user_repository_impl.dart';
|
||||
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
|
||||
import 'package:yumi/ui_kit/components/sc_tts.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:yumi/services/audio/rtc_manager.dart';
|
||||
import 'package:yumi/services/audio/rtm_manager.dart';
|
||||
|
||||
import '../../shared/data_sources/models/enum/sc_auth_type.dart';
|
||||
|
||||
@ -55,6 +58,21 @@ class SocialChatAuthenticationManager extends ChangeNotifier {
|
||||
SCVersionUtils.checkReview(),
|
||||
]);
|
||||
var user = (res[0] as SocialChatLoginRes);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
await Provider.of<RtcProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).resetLocalRoomState(
|
||||
fallbackRtmProvider: Provider.of<RtmProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
),
|
||||
);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
AccountStorage().setCurrentUser(user);
|
||||
SCLoadingManager.hide();
|
||||
notifyListeners();
|
||||
@ -80,6 +98,21 @@ class SocialChatAuthenticationManager extends ChangeNotifier {
|
||||
SCVersionUtils.checkReview(),
|
||||
]);
|
||||
var user = (res[0] as SocialChatLoginRes);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
await Provider.of<RtcProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).resetLocalRoomState(
|
||||
fallbackRtmProvider: Provider.of<RtmProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
),
|
||||
);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
AccountStorage().setCurrentUser(user);
|
||||
SCLoadingManager.hide();
|
||||
notifyListeners();
|
||||
|
||||
@ -34,7 +34,7 @@ class BaseNetworkClient {
|
||||
dio.transformer = BackgroundTransformer()..jsonDecodeCallback = parseJson;
|
||||
dio.options = BaseOptions(
|
||||
connectTimeout: const Duration(seconds: 12),
|
||||
receiveTimeout: const Duration(seconds: 15),
|
||||
receiveTimeout: const Duration(seconds: 30),
|
||||
contentType: 'application/json; charset=UTF-8',
|
||||
);
|
||||
}
|
||||
|
||||
@ -272,18 +272,9 @@ const Map<String, String> _localRouteOverrides = {
|
||||
"/user/vip/ability/update",
|
||||
};
|
||||
|
||||
bool _isLocalGatewayBaseUrl(String baseUrl) {
|
||||
final uri = Uri.tryParse(baseUrl);
|
||||
if (uri == null) return false;
|
||||
return uri.host == "10.0.2.2" ||
|
||||
uri.host == "127.0.0.1" ||
|
||||
uri.host == "localhost";
|
||||
}
|
||||
|
||||
String _resolveRequestPath(String baseUrl, String path) {
|
||||
if (!_isLocalGatewayBaseUrl(baseUrl)) {
|
||||
return path;
|
||||
}
|
||||
// Prefer the known plain-text route when we have one.
|
||||
// This avoids environment-specific AES forwarding mismatches at the gateway.
|
||||
return _localRouteOverrides[path] ?? path;
|
||||
}
|
||||
|
||||
@ -465,7 +456,7 @@ class ResponseData<T> {
|
||||
|
||||
/// 超时拦截器
|
||||
class TimeOutInterceptor extends Interceptor {
|
||||
static const int globalTimeoutSeconds = 15;
|
||||
static const int globalTimeoutSeconds = 25;
|
||||
static const String timeoutSecondsKey = "requestTimeoutSeconds";
|
||||
final Map<String, Timer> _timers = {};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user