From e4e344de6cac9125ea6e10bf1b3ed93675a691f2 Mon Sep 17 00:00:00 2001 From: zu Date: Wed, 1 Dec 2021 17:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=83=A6=E6=AD=BB=E4=BA=86=F0=9F=98=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Main/Room/View/StageView/StageView.m | 76 +++++++------------ 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/xplan-ios/Main/Room/View/StageView/StageView.m b/xplan-ios/Main/Room/View/StageView/StageView.m index 68ab1fd6..1a31a705 100644 --- a/xplan-ios/Main/Room/View/StageView/StageView.m +++ b/xplan-ios/Main/Room/View/StageView/StageView.m @@ -19,7 +19,6 @@ #import "TTPopup.h" #import "XPMacro.h" #import "XPGiftStorage.h" -#import "AccountInfoStorage.h" #import "XCHudTool.h" ///Model #import "AttachmentModel.h" @@ -265,7 +264,7 @@ [self receiveGift:attachment]; } else if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) { NSDictionary * dic = attachment.data; - if (((NSString *)dic[@"uid"]).integerValue == [AccountInfoStorage instance].getUid.integerValue) { + if (((NSString *)dic[@"uid"]).integerValue == self.hostDelegate.getUserInfo.uid) { [self microInvite:dic[@"micPosition"]]; } } @@ -316,32 +315,13 @@ }]; } -#pragma mark - 获取房间角色 -- (RACSignal *)rac_queryChatRoomMember:(NSString *)uid roomId:(NSString *)roomId{ - return [RACSignal createSignal:^RACDisposable *(id subscriber) { - NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; - request.roomId = roomId; - request.userIds = @[uid]; - [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { - if (error == nil) { - [subscriber sendNext:members.firstObject]; - [subscriber sendCompleted]; - }else { - [subscriber sendNext:nil]; - [subscriber sendCompleted]; - } - }]; - return nil; - }]; -} - #pragma mark - StageViewDelegate - 留给子 View 重写的模板方法 - (void)didSelectAtIndex:(NSInteger)index { - NSString * uid = [AccountInfoStorage instance].getUid; MicroQueueModel* micModel = [self.micQueue objectForKey:[self indexToPosition:index]]; UserInfoModel* userInfo = self.hostDelegate.getUserInfo; RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo; NSString* position = [self indexToPosition:index]; + NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid]; NSString* roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; void(^nimUpQueue)(NSString*) = ^ (NSString* up){ @@ -371,8 +351,6 @@ } }]; }; - - TTActionSheetConfig *upMic = [TTActionSheetConfig normalTitle:@"上麦" clickAction:^{ NSString* selfUid = [NSString stringWithFormat:@"%ld", (long)self.hostDelegate.getUserInfo.uid]; @@ -383,39 +361,41 @@ nimUpQueue(position); } }]; - NSString * lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"锁麦" : @"解锁"; TTActionSheetConfig *lockMic = [TTActionSheetConfig normalTitle:lockTitle clickAction:^{ - ///TODO ; 请求接口 + // TODO: 请求接口 }]; NSString * muteTitle = micModel.microState.micState == MicroMicStateType_Open ? @"闭麦" : @"开麦"; TTActionSheetConfig *muteMic = [TTActionSheetConfig normalTitle:muteTitle clickAction:^{ - ///TODO ; 请求接口 + // TODO: 请求接口 }]; - if (micModel.userInfo && micModel.userInfo.uid > 0) {///坑位上有人 展示用户卡片 - NSString * targetUid = [NSString stringWithFormat:@"%ld", micModel.userInfo.uid]; - XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init]; - model.uid = targetUid; - model.position = position; - model.posState = (UserCardMicroPosStateType)micModel.microState.posState; - model.micState = (UserCardMicroMicStateType)micModel.microState.micState; - XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model delegate:self.hostDelegate]; - [self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil]; - } else {///坑位上没人的话 管理员显示上麦/锁麦/闭麦/抱她上麦(目前不做) - [[self rac_queryChatRoomMember:uid roomId:roomId] subscribeNext:^(id _Nullable x) { - NIMChatroomMember * member = x; - if (member == nil) {return;} - if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {///管理员的话 - [TTPopup actionSheetWithItems:@[upMic, lockMic, muteMic]]; - } else {///普通人的话 如果麦位没有锁的话 直接上坑 - if (micModel.microState.posState == MicroPosStateType_Lock) {return;} - nimUpQueue(position); - } - }]; - } + if (micModel.userInfo && micModel.userInfo.uid > 0) { + NSString * targetUid = [NSString stringWithFormat:@"%ld", micModel.userInfo.uid]; + XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init]; + model.uid = targetUid; + model.position = position; + model.posState = (UserCardMicroPosStateType)micModel.microState.posState; + model.micState = (UserCardMicroMicStateType)micModel.microState.micState; + XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model delegate:self.hostDelegate]; + [self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil]; + } else { + NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; + request.roomId = roomId; + request.userIds = @[uid]; + [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + NIMChatroomMember * member = members.firstObject; + if (member == nil) {return;} + if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {///管理员的话 + [TTPopup actionSheetWithItems:@[upMic, lockMic, muteMic]]; + } else { + if (micModel.microState.posState == MicroPosStateType_Lock) return; + nimUpQueue(position); + } + }]; + } } - (NSInteger)countOfMircoView {