Browse Source

优化防抖

dev-2.0
YakumoChen 3 days ago
parent
commit
39cf607beb
1 changed files with 11 additions and 0 deletions
  1. 11
      lib/controller/discover/room_controller.dart

11
lib/controller/discover/room_controller.dart

@ -640,7 +640,11 @@ class RoomController extends GetxController with WidgetsBindingObserver {
} }
} }
bool isClick = false;
Future<void> joinChat(CurrentRole role) async { Future<void> joinChat(CurrentRole role) async {
if(isClick) return;
isClick = true;
// / // /
bool granted = false; bool granted = false;
if (role == CurrentRole.maleAudience || role == CurrentRole.femaleAudience) { if (role == CurrentRole.maleAudience || role == CurrentRole.femaleAudience) {
@ -652,6 +656,7 @@ class RoomController extends GetxController with WidgetsBindingObserver {
} }
if (!granted) { if (!granted) {
print('❌ [RoomController] 权限检查失败,无法上麦'); print('❌ [RoomController] 权限检查失败,无法上麦');
isClick = false;
return; return;
} }
final data = { final data = {
@ -671,9 +676,11 @@ class RoomController extends GetxController with WidgetsBindingObserver {
discoverController.loadRtcChannelPage(); discoverController.loadRtcChannelPage();
} }
SmartDialog.showToast(response.data.message); SmartDialog.showToast(response.data.message);
isClick = false;
return; return;
} }
if (!response.data.data['success']) { if (!response.data.data['success']) {
isClick = false;
return; return;
} }
currentRole = role; currentRole = role;
@ -712,9 +719,12 @@ class RoomController extends GetxController with WidgetsBindingObserver {
); );
rtcChannelDetail.value = newDetail; rtcChannelDetail.value = newDetail;
isLive.value = true; isLive.value = true;
isClick = false;
} }
Future<void> leaveChat() async { Future<void> leaveChat() async {
if(isClick) return;
isClick = true;
final data = {'channelId': RTCManager.instance.currentChannelId}; final data = {'channelId': RTCManager.instance.currentChannelId};
final response = await _networkService.rtcApi.disconnectRtcChannel(data); final response = await _networkService.rtcApi.disconnectRtcChannel(data);
if (response.data.isSuccess) { if (response.data.isSuccess) {
@ -739,6 +749,7 @@ class RoomController extends GetxController with WidgetsBindingObserver {
} }
currentRole = CurrentRole.normalUser; currentRole = CurrentRole.normalUser;
} }
isClick = false;
} }
/// RTC /// RTC

Loading…
Cancel
Save