进房逻辑简化

This commit is contained in:
zu
2021-10-21 17:55:51 +08:00
parent cdcfda385f
commit 1a9a925a61
8 changed files with 40 additions and 169 deletions

View File

@@ -26,7 +26,6 @@
#import "XPRoomProtocol.h"
///Category
#import "XPRoomViewController+RoomInfoContainerView.h"
#import "XPRoomViewController+SDKConfig.h"
@interface XPRoomViewController ()<XPRoomProtocol>
///
@@ -41,8 +40,6 @@
@property (nonatomic,strong) XPRoomMenuContainerView *menuContainerView;
///
@property (nonatomic,strong) XPRoomActivityContainerView *activityContainerView;
///
@property (nonatomic,assign) BOOL isOpenRoom;
///
@property (nonatomic,strong) UserInfoModel *usereInfo;
///
@@ -70,6 +67,11 @@
[self initSubViewConstraints];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.presenter getRoomInfoWithUid:self.roomUid];
}
#pragma mark - Private Method
- (void)initSubViews {
[self.view addSubview:self.backContainerView];
@@ -117,107 +119,33 @@
}];
}
///
- (void)requestRoomInfoSuccess:(RoomInfoModel *)roomInfo {
[self hideHUD];
self.roomInfo = roomInfo;
[self configRoomInfoContainerViewWithRoomInfo:roomInfo];
///
if (self.usereInfo == nil) {
[self.presenter getUserInfoWithUid:self.roomUid];
} else {
[self enterChatRoomWithUseInfo:self.usereInfo];
}
}
///dismissVC
- (void)disMissRoomVC {
if (self.presentingViewController) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
///
- (void)openRoomWithUserInfo {
NSString * title = [NSString stringWithFormat:@"%@的房间", self.usereInfo.nick];
[self.presenter openUserRoomWithTitle:title type:RoomType_Game roomPwd:@"" roomDesc:@"" backPic:@""];
}
- (void)enterChatRoomWithUseInfo:(UserInfoModel *)userInfo {
///
#warning to do -
[self configEnterRoomSDK];
}
#pragma mark - XPRoomProtocol
- (void)getRoomInfoSuccess:(RoomInfoModel *)roomInfo {
NSString * uid = [AccountInfoStorage instance].getUid;
if ([self.roomUid isEqualToString:uid]) {///
if (roomInfo == nil || !roomInfo.valid) {
self.isOpenRoom = YES;
if (self.usereInfo) {
[self openRoomWithUserInfo];
} else {
[self.presenter getUserInfoWithUid:uid];
}
} else {
[self requestRoomInfoSuccess:roomInfo];
}
} else {///
if (roomInfo.valid) {
if (roomInfo.roomPwd.length > 0) {
[self hideHUD];
#warning to do -
} else {
[self requestRoomInfoSuccess:roomInfo];
}
} else {
#warning to do - 线
[self hideHUD];
}
}
}
- (void)getRoomInfoFail {
[self hideHUD];
[self disMissRoomVC];
NSString * uid = [AccountInfoStorage instance].getUid;
if (roomInfo.valid) {
[self configRoomInfoContainerViewWithRoomInfo:roomInfo]; // S1
[self.presenter getUserInfoWithUid:uid];
} else {
if ([self.roomUid isEqualToString:uid]) {
// TODO:
} else {
// TODO: 线
}
}
}
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
self.usereInfo = userInfo;
if (self.isOpenRoom) {
[self openRoomWithUserInfo];
} else {
if (self.roomInfo) {
[self enterChatRoomWithUseInfo:userInfo];
}
}
}
- (void)getUserInfoFail {
[self hideHUD];
[self disMissRoomVC];
// TODO:
}
- (void)openRoomSuccess:(RoomInfoModel *)roomInfo {
[self requestRoomInfoSuccess:roomInfo];
[self configRoomInfoContainerViewWithRoomInfo:roomInfo];
// TODO:
}
- (void)openRoomFail {
[self hideHUD];
[self disMissRoomVC];
}
#pragma mark - Getters And Setters
- (void)setRoomUid:(NSString *)roomUid {
_roomUid = roomUid;
if (_roomUid) {
[self showLoading];
///
[self.presenter getUserInfoWithUid:_roomUid];
///
[self.presenter getRoomInfoWithUid:_roomUid];
}
- (void)enterRoomFail {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (XPRoomBackContainerView *)backContainerView {