更多菜单栏增加清除房间公屏

This commit is contained in:
chenguilong
2022-04-25 17:45:57 +08:00
parent 514081b699
commit eb373ad8aa
12 changed files with 154 additions and 14 deletions

View File

@@ -147,6 +147,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageSubUpdateRoomInfo) {
Custom_Message_Sub_Update_RoomInfo_Notice = 204, Custom_Message_Sub_Update_RoomInfo_Notice = 204,
///红包开关通知 ///红包开关通知
Custom_Message_Sub_Update_RoomInfo_RedPacket = 205, Custom_Message_Sub_Update_RoomInfo_RedPacket = 205,
///清空公屏
Custom_Message_Sub_Update_RoomInfo_CleanScreen = 206,
}; };
///first = CustomMessageType_Candy_Tree ///first = CustomMessageType_Candy_Tree

View File

@@ -139,6 +139,8 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) {
@property (nonatomic, copy) NSString *pkUid; @property (nonatomic, copy) NSString *pkUid;
///PK中的对方房间roomId(本地字段) ///PK中的对方房间roomId(本地字段)
@property (nonatomic, copy) NSString *pkRoomId; @property (nonatomic, copy) NSString *pkRoomId;
///清除公屏的时间(用于拉取此时间后的公屏消息)
@property (nonatomic , assign) double clearScreenTime;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -315,7 +315,28 @@
[attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@"room_menu_more"]]]; [attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@"room_menu_more"]]];
[attribute appendAttributedString:[self createTextAttribute:@"图标即可开启" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createTextAttribute:@"图标即可开启" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
return attribute; return attribute;
} } else if (attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
NSNumber *roleType = attachment.data[@"roleType"];
NSString *nick = attachment.data[@"nick"];
NSInteger uid = 0;
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
}
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
[attribute appendAttributedString:[self createTextAttribute:@"消息:" color:[ThemeColor messageNickColor] font:kRoomMessageDefalutFont]];
if (roleType.integerValue == 1) {
[attribute appendAttributedString:[self createTextAttribute:@"房主" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:nick color:[ThemeColor messageNickColor] font:kRoomMessageDefalutFont]];
} else if (roleType.integerValue == 2) {
[attribute appendAttributedString:[self createTextAttribute:@"管理员" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:nick color:[ThemeColor messageNickColor] font:kRoomMessageDefalutFont]];
}
[attribute appendAttributedString:[self createTextAttribute:@"已清空房间公屏消息" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[self attributeAddHihtLight:attribute uid:uid];
return attribute;
}
return nil; return nil;
} }

View File

@@ -494,9 +494,23 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
[self.locationArray removeAllObjects]; [self.locationArray removeAllObjects];
self.atCount = 0; self.atCount = 0;
self.atTipBtn.hidden = YES; self.atTipBtn.hidden = YES;
[[XPRoomMiniManager shareManager] resetLocalMessage]; self.messageTipsBtn.hidden = YES;
self.isPending = NO;
[[XPRoomMiniManager shareManager] resetLocalMessage];
[self addRoomMessage:message]; [self addRoomMessage:message];
return; return;
} else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
[self.datasource removeAllObjects];
[self.incomingMessages removeAllObjects];
[self.messageBubbles removeAllObjects];
[self.locationArray removeAllObjects];
self.atCount = 0;
self.atTipBtn.hidden = YES;
self.messageTipsBtn.hidden = YES;
self.isPending = NO;
[[XPRoomMiniManager shareManager] resetLocalMessage];
[self addRoomMessage:message];
return;
} }
} }
if (self.hostDelegate.getRoomInfo.isCloseScreen) { if (self.hostDelegate.getRoomInfo.isCloseScreen) {
@@ -525,14 +539,56 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
[self addRoomMessage:message]; [self addRoomMessage:message];
return; return;
} else { } else {
[self addRoomMessage:message];
NIMChatroomNotificationMember *member = content.targets[0]; NIMChatroomNotificationMember *member = content.targets[0];
if (member.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue) { if (member.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
if (!roomInfo.hasAnimationEffect) { ///
[self roomInfoNoGiftAnimationMessage:message]; NSString *roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
} NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
[self createUserEnterRoomAddRoomtopicMessage]; option.limit = [ClientConfig shareConfig].configInfo.roomMessageCount;
} option.startTime = self.hostDelegate.getRoomInfo.clearScreenTime / 1000.0;
option.order = NIMMessageSearchOrderAsc;
option.messageTypes = @[@(NIMMessageTypeText)];
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
if (messages.count) {
if (self.datasource.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
[self.datasource removeObjectsInArray:needRemoveMsgArray];
[self.messageBubbles removeObjectsAtIndexes:set];
}
//
for (NIMMessage *item in messages) {
[self.datasource addObject:[self.messageParser parseMessageAttribute:item]];
[self.messageBubbles addObject:[self.messageParser parseMessageBubble:item]];
if (!self.isMiniEnter) {///
if (self.hostDelegate.getRoomInfo.isCloseScreen) {
NIMCustomObject *obj = (NIMCustomObject *)item.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState){
[[XPRoomMiniManager shareManager] saveRoomMessage:item];
}
}
} else {
[[XPRoomMiniManager shareManager] saveRoomMessage:item];
}
}
}
[self.messageTableView reloadData];
//
[self scrollToBottom:YES];
}
///
[self addRoomMessage:message];
if (!roomInfo.hasAnimationEffect) {
[self roomInfoNoGiftAnimationMessage:message];
}
[self createUserEnterRoomAddRoomtopicMessage];
}];
} else {
[self addRoomMessage:message];
}
} }
} else if(content.eventType == NIMChatroomEventTypeInfoUpdated) { } else if(content.eventType == NIMChatroomEventTypeInfoUpdated) {
if (roomInfo.isCloseScreen) {return;} if (roomInfo.isCloseScreen) {return;}

View File

@@ -64,6 +64,12 @@ NS_ASSUME_NONNULL_BEGIN
/// @param roundId PK场次id /// @param roundId PK场次id
+ (void)requestEndAnchorRoomPk:(HttpRequestHelperCompletion)completion roundId:(NSString *)roundId; + (void)requestEndAnchorRoomPk:(HttpRequestHelperCompletion)completion roundId:(NSString *)roundId;
/// 清空公屏
/// @param completion 完成
/// @param roomUid 房间uid
/// @param uid 操作人uid
+ (void)requestCleanScreen:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid uid:(NSString *)uid;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -80,4 +80,13 @@
+ (void)requestEndAnchorRoomPk:(HttpRequestHelperCompletion)completion roundId:(NSString *)roundId { + (void)requestEndAnchorRoomPk:(HttpRequestHelperCompletion)completion roundId:(NSString *)roundId {
[self makeRequest:@"crossroompkround/endSingleRoomPk" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roundId, nil]; [self makeRequest:@"crossroompkround/endSingleRoomPk" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roundId, nil];
} }
///
/// @param completion
/// @param roomUid uid
/// @param uid uid
+ (void)requestCleanScreen:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid uid:(NSString *)uid {
[self makeRequest:@"room/clear/history/recrod" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, uid, nil];
}
@end @end

View File

@@ -42,6 +42,8 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
RoomMoreMenuType_Room_Anchor_PK_Open = 15, RoomMoreMenuType_Room_Anchor_PK_Open = 15,
///关闭主播Pk ///关闭主播Pk
RoomMoreMenuType_Room_Anchor_PK_Close = 16, RoomMoreMenuType_Room_Anchor_PK_Close = 16,
///清空公屏
RoomMoreMenuType_Message_Screen_Clear = 17,
}; };
@interface XPRoomMoreItemModel : NSObject @interface XPRoomMoreItemModel : NSObject

View File

@@ -45,6 +45,10 @@ NS_ASSUME_NONNULL_BEGIN
///结束个播跨房PK ///结束个播跨房PK
- (void)requestFinishAnchorPK:(NSString *)roundId; - (void)requestFinishAnchorPK:(NSString *)roundId;
/// 清空公屏
/// @param roomUid 房主的uid
/// @param uid 操作人的uid
- (void)cleanScreen:(NSString *)roomUid uid:(NSString *)uid;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -64,12 +64,18 @@
} else if (roomInfo.pkState == AcrossRoomPkStateTypePenaltyEnd) { } else if (roomInfo.pkState == AcrossRoomPkStateTypePenaltyEnd) {
anchorRoomPK.title = @"结束PK"; anchorRoomPK.title = @"结束PK";
} }
XPRoomMoreItemModel * messageScreen = [[XPRoomMoreItemModel alloc] init]; XPRoomMoreItemModel * messageScreen = [[XPRoomMoreItemModel alloc] init];
messageScreen.title = roomInfo.isCloseScreen ? @"开启公屏" : @"关闭公屏"; messageScreen.title = roomInfo.isCloseScreen ? @"开启公屏" : @"关闭公屏";
messageScreen.imageName = roomInfo.isCloseScreen ? @"room_more_menu_message_open" : @"room_more_menu_message_close"; messageScreen.imageName = roomInfo.isCloseScreen ? @"room_more_menu_message_open" : @"room_more_menu_message_close";
messageScreen.type = roomInfo.isCloseScreen ? RoomMoreMenuType_Message_Screen_Open : RoomMoreMenuType_Message_Screen_Close; messageScreen.type = roomInfo.isCloseScreen ? RoomMoreMenuType_Message_Screen_Open : RoomMoreMenuType_Message_Screen_Close;
messageScreen.titleColor = roomInfo.isCloseScreen ? nil : [ThemeColor roomMoreMenuTextColor]; messageScreen.titleColor = roomInfo.isCloseScreen ? nil : [ThemeColor roomMoreMenuTextColor];
XPRoomMoreItemModel * clearScreen = [[XPRoomMoreItemModel alloc] init];
clearScreen.title = @"清空公屏";
clearScreen.imageName = roomInfo.isCloseScreen ? @"room_more_menu_message_open" : @"room_more_menu_message_close";
clearScreen.type = RoomMoreMenuType_Message_Screen_Clear;
clearScreen.titleColor = [ThemeColor roomMoreMenuTextColor];
XPRoomMoreItemModel * roomSetting = [[XPRoomMoreItemModel alloc] init]; XPRoomMoreItemModel * roomSetting = [[XPRoomMoreItemModel alloc] init];
roomSetting.title = @"房间设置"; roomSetting.title = @"房间设置";
@@ -120,6 +126,7 @@
[array addObject:dating]; [array addObject:dating];
} }
[array addObject:messageScreen]; [array addObject:messageScreen];
[array addObject:clearScreen];
[array addObject:giftValue]; [array addObject:giftValue];
[array addObject:roomSetting]; [array addObject:roomSetting];
[array addObject:inviteFriend]; [array addObject:inviteFriend];
@@ -204,4 +211,14 @@
[[self getView] endAnchorPkSuccess:code == 200 msg:msg]; [[self getView] endAnchorPkSuccess:code == 200 msg:msg];
} roundId:roundId]; } roundId:roundId];
} }
///
/// @param roomUid uid
/// @param uid uid
- (void)cleanScreen:(NSString *)roomUid uid:(NSString *)uid {
[Api requestCleanScreen:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] cleanScreenSuccess];
}] roomUid:roomUid uid:uid];
}
@end @end

View File

@@ -30,6 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getTrumpetSuccess:(XPNobleTrumpetModel *)model; - (void)getTrumpetSuccess:(XPNobleTrumpetModel *)model;
///结束个播跨房PK回调 ///结束个播跨房PK回调
- (void)endAnchorPkSuccess:(BOOL)success msg:(NSString *)msg; - (void)endAnchorPkSuccess:(BOOL)success msg:(NSString *)msg;
///清空公屏成功
- (void)cleanScreenSuccess;
@end @end

View File

@@ -154,6 +154,11 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }
///
- (void)cleanScreenSuccess {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)openRoomDatingSuccess { - (void)openRoomDatingSuccess {
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }
@@ -350,6 +355,18 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
} }
break; break;
case RoomMoreMenuType_Message_Screen_Clear:
{
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.title = @"提示";
config.message = @"确定要清空公屏消息吗?\n(清空后不可恢复哦~)";
config.confirmButtonConfig.title = @"确定";
[TTPopup alertWithConfig:config confirmHandler:^{
[self.presenter cleanScreen:roomUid uid:[AccountInfoStorage instance].getUid];
} cancelHandler:^{
}];
}
break;
default: default:
break; break;
} }

View File

@@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,copy) NSDictionary *faceInitData; @property (nonatomic,copy) NSDictionary *faceInitData;
///是否隐藏房间公告 ///是否隐藏房间公告
@property (nonatomic,assign) BOOL appStoreAuditNoticeVersion; @property (nonatomic,assign) BOOL appStoreAuditNoticeVersion;
//进入房间拉取N条聊天数据
@property(nonatomic, assign) NSInteger roomMessageCount;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END