Commit 425bf39e authored by Kevin Reynaldo's avatar Kevin Reynaldo
Browse files

• Updated version to 1.3.18

• Added getMediaMessagesFromRoom method to TAPCoreMessageManager
• Added setReportButtonInChatProfileVisible to TapUI
• Added TapUIChatProfileDelegate
• Added getUnreadMessagesFromRoom method to TAPCoreMessageManagerDelegate
• Fixed TAPCoreMessageManager deleteMessage success callback not called
• Fixed sendCustomMessage callback not called
• Fixed sendForwardedMessage callbacks not called
• Added thumbnail to sendVideoMessageWithVideoAssetURL
parent a4b035bf
......@@ -3,7 +3,7 @@ Pod::Spec.new do |s|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
s.name = "TapTalk"
s.version = "1.3.17"
s.version = "1.3.18"
s.summary = "TapTalk.io is a complete in-app chat SDK and messaging API. TapTalk.io provides UI-based and code-based implementation & fully customizable."
s.homepage = "https://taptalk.io"
......
......@@ -2153,7 +2153,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.17;
MARKETING_VERSION = 1.3.18;
PRODUCT_BUNDLE_IDENTIFIER = io.TapTalk.TapTalk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
......@@ -2190,7 +2190,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.17;
MARKETING_VERSION = 1.3.18;
PRODUCT_BUNDLE_IDENTIFIER = io.TapTalk.TapTalk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
......
......@@ -574,7 +574,12 @@
}];
}
- (void)sendVideoMessageWithVideoAssetURL:(NSURL *)videoAssetURL caption:(NSString *)caption thumbnailImageData:(NSData *)thumbnailImageData room:(TAPRoomModel *)room successGenerateMessage:(void (^)(TAPMessageModel *message))successGenerateMessage {
- (void)sendVideoMessageWithVideoAssetURL:(NSURL *)videoAssetURL
caption:(NSString *)caption
thumbnailImageData:(NSData *)thumbnailImageData
room:(TAPRoomModel *)room
successGenerateMessage:(void (^)(TAPMessageModel *message))successGenerateMessage {
//Check if forward message exist, send forward message
[self checkAndSendForwardedMessageWithRoom:room];
......
......@@ -233,6 +233,14 @@ NS_ASSUME_NONNULL_BEGIN
NSArray <TAPMessageModel *> *olderMessagesArray,
NSArray <TAPMessageModel *> *newerMessagesArray))successAllMessages
failure:(void (^)(NSError *error))failure;
- (void)getUnreadMessagesFromRoom:(NSString *)roomID
success:(void (^)(NSArray<TAPMessageModel *> *unreadMessageArray))success
failure:(void (^)(NSError *error))failure;
- (void)getMediaMessagesFromRoom:(NSString *)roomID
lastTimestamp:(NSNumber *)lastTimestamp
numberOfItem:(NSInteger)numberOfItem
success:(void (^)(NSArray<TAPMessageModel *> *mediaMessageArray))success
failure:(void (^)(NSError *error))failure;
@end
NS_ASSUME_NONNULL_END
......@@ -469,27 +469,60 @@
//END - Retrieve the video frame at 1 sec to define the video thumbnail
[[TAPChatManager sharedManager] sendVideoMessageWithVideoAssetURL:videoAssetURL
caption:caption
thumbnailImageData:nil
room:room
successGenerateMessage:^(TAPMessageModel *message) {
//Handle block to dictionary
NSMutableDictionary *blockTypeDictionary = [[NSMutableDictionary alloc] init];
void (^handlerProgress)(TAPMessageModel *, CGFloat, CGFloat) = [progress copy];
[blockTypeDictionary setObject:handlerProgress forKey:@"progressBlock"];
void (^handlerSuccess)(TAPMessageModel *) = [success copy];
[blockTypeDictionary setObject:handlerSuccess forKey:@"successBlock"];
void (^handlerFailure)(NSError *) = [failure copy];
[blockTypeDictionary setObject:handlerFailure forKey:@"failureBlock"];
[self.blockDictionary setObject:blockTypeDictionary forKey:message.localID];
start(message);
}];
AVAsset *videoAsset = [AVAsset assetWithURL:videoAssetURL];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:videoAsset];
generator.appliesPreferredTrackTransform = YES;
CMTime thumbTime = CMTimeMake(1, 1);
// CGFloat videoLength = ((float) videoAsset.duration.value) / ((float) videoAsset.duration.timescale);
// CMTime thumbTime = CMTimeMakeWithSeconds(videoLength, 2.0);
//Handle block to dictionary
NSMutableDictionary *blockTypeDictionary = [[NSMutableDictionary alloc] init];
void (^handlerProgress)(TAPMessageModel *, CGFloat, CGFloat) = [progress copy];
[blockTypeDictionary setObject:handlerProgress forKey:@"progressBlock"];
void (^handlerSuccess)(TAPMessageModel *) = [success copy];
[blockTypeDictionary setObject:handlerSuccess forKey:@"successBlock"];
void (^handlerFailure)(NSError *) = [failure copy];
[blockTypeDictionary setObject:handlerFailure forKey:@"failureBlock"];
AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef imageRef, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
if (result != AVAssetImageGeneratorSucceeded) {
// Error when generating thumbnail
dispatch_async(dispatch_get_main_queue(), ^{
[[TAPChatManager sharedManager] sendVideoMessageWithVideoAssetURL:videoAssetURL
caption:caption
thumbnailImageData:nil
room:room
successGenerateMessage:^(TAPMessageModel *message) {
[self.blockDictionary setObject:blockTypeDictionary forKey:message.localID];
start(message);
}];
});
}
else {
// Thumbnail generated
UIImage *videoThumbnailImage = [[UIImage alloc] initWithCGImage:imageRef];
NSData *videoThumbnailImageData = UIImageJPEGRepresentation(videoThumbnailImage, 1.0f);
dispatch_async(dispatch_get_main_queue(), ^{
[[TAPChatManager sharedManager] sendVideoMessageWithVideoAssetURL:videoAssetURL
caption:caption
thumbnailImageData:videoThumbnailImageData
room:room
successGenerateMessage:^(TAPMessageModel *message) {
[self.blockDictionary setObject:blockTypeDictionary forKey:message.localID];
start(message);
}];
});
}
};
[generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];
});
}
......@@ -584,6 +617,7 @@
progress:(void (^)(TAPMessageModel *message, CGFloat progress, CGFloat total))progress
success:(void (^)(TAPMessageModel *message))success
failure:(void (^)(NSError *error))failure {
if (messageToForward.type == TAPChatMessageTypeFile || messageToForward.type == TAPChatMessageTypeVideo) {
NSDictionary *dataDictionary = messageToForward.data;
NSString *fileID = [dataDictionary objectForKey:@"fileID"];
......@@ -595,9 +629,45 @@
}
}
[[TAPChatManager sharedManager] saveToQuoteActionWithType:TAPChatManagerQuoteActionTypeForward roomID:room.roomID];
[[TAPChatManager sharedManager] saveToQuotedMessage:messageToForward userInfo:[NSDictionary dictionary] roomID:room.roomID];
[[TAPChatManager sharedManager] checkAndSendForwardedMessageWithRoom:room];
TAPMessageModel *message = [TAPMessageModel createMessageWithUser:[TAPChatManager sharedManager].activeUser
room:room
body:messageToForward.body
type:messageToForward.type
messageData:nil];
message.data = messageToForward.data;
message.quote = messageToForward.quote;
message.replyTo = messageToForward.replyTo;
if (messageToForward.forwardFrom.localID != nil && ![messageToForward.forwardFrom.localID isEqualToString:@""]) {
//Obtain existing forward from model
message.forwardFrom = messageToForward.forwardFrom;
}
else {
//Create forward from model
TAPForwardFromModel *forwardFrom = [TAPForwardFromModel new];
forwardFrom.userID = messageToForward.user.userID;
forwardFrom.xcUserID = messageToForward.user.xcUserID;
forwardFrom.fullname = messageToForward.user.fullname;
forwardFrom.messageID = messageToForward.messageID;
forwardFrom.localID = messageToForward.localID;
message.forwardFrom = forwardFrom;
}
[self sendCustomMessageWithMessageModel:message
start:^(TAPMessageModel * _Nonnull message) {
start(message);
}
success:^(TAPMessageModel * _Nonnull message) {
success(message);
}
failure:^(NSError * _Nonnull error) {
failure(error);
}];
// [[TAPChatManager sharedManager] saveToQuoteActionWithType:TAPChatManagerQuoteActionTypeForward roomID:room.roomID];
// [[TAPChatManager sharedManager] saveToQuotedMessage:messageToForward userInfo:[NSDictionary dictionary] roomID:room.roomID];
// [[TAPChatManager sharedManager] checkAndSendForwardedMessageWithRoom:room];
}
- (TAPMessageModel *)constructTapTalkMessageModelWithRoom:(TAPRoomModel *)room
......@@ -687,12 +757,12 @@
start:(void (^)(TAPMessageModel *message))start
success:(void (^)(TAPMessageModel *message))success
failure:(void (^)(NSError *error))failure {
[[TAPChatManager sharedManager] sendCustomMessage:customMessage];
void (^handlerSuccess)(TAPMessageModel *) = [success copy];
NSMutableDictionary *blockTypeDictionary = [[NSMutableDictionary alloc] init];
[blockTypeDictionary setObject:handlerSuccess forKey:@"successBlock"];
[self.blockDictionary setObject:blockTypeDictionary forKey:customMessage.localID];
start(customMessage);
[[TAPChatManager sharedManager] sendCustomMessage:customMessage];
}
- (void)sendProductMessageWithProductArray:(NSArray <NSDictionary*> *)productArray
......@@ -705,21 +775,25 @@
TAPMessageModel *constructedMessage = [self constructTapTalkMessageModelWithRoom:room messageBody:@"Product List" messageType:TAPChatMessageTypeProduct messageData:dataDictionary];
[[TAPChatManager sharedManager] sendProductMessage:constructedMessage];
void (^handlerSuccess)(TAPMessageModel *) = [success copy];
NSMutableDictionary *blockTypeDictionary = [[NSMutableDictionary alloc] init];
[blockTypeDictionary setObject:handlerSuccess forKey:@"successBlock"];
[self.blockDictionary setObject:blockTypeDictionary forKey:constructedMessage.localID];
start(constructedMessage);
[[TAPChatManager sharedManager] sendProductMessage:constructedMessage];
}
- (void)deleteMessage:(TAPMessageModel *)message
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure {
[TAPDataManager callAPIDeleteMessageWithMessageIDs:@[message.messageID] roomID:message.room.roomID isDeletedForEveryone:YES success:^(NSArray *deletedMessageIDArray) {
success;
} failure:^(NSError *error) {
[TAPDataManager callAPIDeleteMessageWithMessageIDs:@[message.messageID]
roomID:message.room.roomID
isDeletedForEveryone:YES
success:^(NSArray *deletedMessageIDArray) {
success();
}
failure:^(NSError *error) {
failure(error);
}];
}
......@@ -1065,4 +1139,42 @@
}];
}
- (void)getUnreadMessagesFromRoom:(NSString *)roomID
success:(void (^)(NSArray<TAPMessageModel *> *unreadMessageArray))success
failure:(void (^)(NSError *error))failure {
[TAPDataManager getDatabaseUnreadMessagesInRoomWithRoomID:roomID
activeUserID:[[TapTalk sharedInstance] getTapTalkActiveUser].userID
success:^(NSArray *unreadMessages) {
success(unreadMessages);
}
failure:^(NSError *error) {
failure(error);
}];
}
- (void)getMediaMessagesFromRoom:(NSString *)roomID
lastTimestamp:(NSNumber *)lastTimestamp
numberOfItem:(NSInteger)numberOfItem
success:(void (^)(NSArray<TAPMessageModel *> *mediaMessageArray))success
failure:(void (^)(NSError *error))failure {
NSString *lastTimestampString;
if ([lastTimestamp longValue] <= 0L) {
lastTimestampString = @"";
}
else {
lastTimestampString = [lastTimestamp stringValue];
}
[TAPDataManager getDatabaseMediaMessagesInRoomWithRoomID:roomID
lastTimestamp:lastTimestampString
numberOfItem:numberOfItem
success:^(NSArray *mediaMessages) {
success(mediaMessages);
}
failure:^(NSError *error) {
failure(error);
}];
}
@end
......@@ -475,7 +475,6 @@
[data writeToFile:destinationFileString atomically:YES];
// TODO: ADD FILE PATH SUCCESS CALLBACK (?)
[[TAPFileDownloadManager sharedManager] saveDownloadedFilePathToDictionaryWithFilePath:destinationFileString roomID:message.room.roomID fileID:key];
[self.failedDownloadDictionary removeObjectForKey:message.localID];
......
......@@ -170,6 +170,7 @@ typedef NS_ENUM(NSInteger, TAPComponentColor) {
TAPComponentColorIconGroupMemberProfileMenuPromoteAdmin, //Chat / Group Profile Page
TAPComponentColorIconGroupMemberProfileMenuDemoteAdmin, //Chat / Group Profile Page
TAPComponentColorIconGroupMemberProfileMenuRemoveMember, //Chat / Group Profile Page
TAPComponentColorIconGroupMemberProfileMenuReportUserOrGroup, //Chat / Group Profile Page
TAPComponentColorIconMediaPreviewAdd, //Media / Image Detail Preview
TAPComponentColorIconMediaPreviewWarning, //Media / Image Detail Preview
TAPComponentColorIconMediaPreviewThumbnailWarning,//Media / Image Detail Preview
......
......@@ -2955,6 +2955,12 @@
return color;
break;
}
case TAPComponentColorIconGroupMemberProfileMenuReportUserOrGroup:
{
UIColor *color = [[TAPStyleManager sharedManager] getDefaultColorForType:TAPDefaultColorIconDestructive];
return color;
break;
}
//Media / Image Detail Preview
case TAPComponentColorIconMediaPreviewAdd:
{
......
{
"images" : [
{
"filename" : "TAPIconFlag.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "TAPIconFlag@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "TAPIconFlag@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -150,7 +150,7 @@ Called when user click mention in the bubble chat.
Called when user click the profile button on the top left side of room list view.
@param currentViewController (UIViewController *) current shown view controller
@param currentNavigationController (TapUserModel *) current shown navigation controller, you can handle push or push using this navigation controller
@param currentNavigationController (UINavigationController *) current shown navigation controller, you can handle push or push using this navigation controller
*/
- (void)tapTalkAccountButtonTapped:(UIViewController *)currentViewController
currentShownNavigationController:(UINavigationController *)currentNavigationController;
......@@ -159,12 +159,40 @@ Called when user click mention in the bubble chat.
Called when user click the new chat button on the top right side of room list view.
@param currentViewController (UIViewController *) current shown view controller
@param currentNavigationController (TapUserModel *) current shown navigation controller, you can handle push or push using this navigation controller
@param currentNavigationController (UINavigationController *) current shown navigation controller, you can handle push or push using this navigation controller
*/
- (void)tapTalkNewChatButtonTapped:(UIViewController *)currentViewController
currentShownNavigationController:(UINavigationController *)currentNavigationController;
@end
//==========================================================
// TapUIChatProfileDelegate
//==========================================================
@protocol TapUIChatProfileDelegate <NSObject>
@optional
/**
Called when user taps the Report User button in chat profile
@param currentViewController (UIViewController *) current shown view controller
@param room (TAPRoomModel *) chat room details of the reported user
@param reportedUser (TapUserModel *) details of the reported user
*/
- (void)reportUserButtonDidTapped:(UIViewController *)currentViewController
room:(TAPRoomModel *)room
user:(TAPUserModel *)reportedUser;
/**
Called when user taps the Report Group button in chat profile
@param currentViewController (UIViewController *) current shown view controller
@param room (TAPRoomModel *) chat room details of the reported group
*/
- (void)reportGroupButtonDidTapped:(UIViewController *)currentViewController
room:(TAPRoomModel *)room;
@end
//==========================================================
// TapUICustomKeyboardDelegate
//==========================================================
......@@ -203,6 +231,7 @@ https://developer.taptalk.io/docs/event-delegate#section-tapuicustomkeyboarddele
@property (weak, nonatomic) UIWindow *activeWindow;
@property (weak, nonatomic) id<TapUIChatRoomDelegate> chatRoomDelegate;
@property (weak, nonatomic) id<TapUIRoomListDelegate> roomListDelegate;
@property (weak, nonatomic) id<TapUIChatProfileDelegate> chatProfileDelegate;
@property (weak, nonatomic) id<TapUICustomKeyboardDelegate> customKeyboardDelegate;
//Initalization
......@@ -691,6 +720,15 @@ Get current status of adding contacts & contact list
*/
- (BOOL)isAddContactEnabled;
/**
Show or hide report button in user/group profile page
*/
- (void)setReportButtonInChatProfileVisible:(BOOL)isVisible;
/**
Get current visibility state of report button in user/group profile page
*/
- (BOOL)getReportButtonInChatProfileVisibleState;
@end
NS_ASSUME_NONNULL_END
......@@ -47,6 +47,7 @@
@property (nonatomic) BOOL isAddToContactsButtonInChatRoomHidden;
@property (nonatomic) BOOL isAddToContactsButtonInChatProfileHidden;
@property (nonatomic) BOOL isAddContactDisabled;
@property (nonatomic) BOOL isReportButtonInChatProfileVisible;
- (UIViewController *)topViewControllerWithRootViewController:(UIViewController *)rootViewController;
......@@ -814,4 +815,18 @@ Get current status of adding contacts & contact list
return !self.isAddContactDisabled;
}
/**
Show or hide report button in user/group profile page
*/
- (void)setReportButtonInChatProfileVisible:(BOOL)isVisible {
_isReportButtonInChatProfileVisible = isVisible;
}
/**
Get current visibility state of report button in user/group profile page
*/
- (BOOL)getReportButtonInChatProfileVisibleState {
return self.isReportButtonInChatProfileVisible;
}
@end
......@@ -234,6 +234,29 @@
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
CGFloat height = 56.0f;
if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeDefault) {
if (self.room.type == RoomTypePersonal) {
if (indexPath.row == 0) {
//add to contacts
NSString *otherUserID = [[TAPChatManager sharedManager] getOtherUserIDWithRoomID:self.room.roomID];
TAPUserModel *user = [[TAPContactManager sharedManager] getUserWithUserID:otherUserID];
if (![[TapUI sharedInstance] isAddContactEnabled] ||
![[TapUI sharedInstance] getAddToContactsButtonInChatRoomVisibleState] ||
user != nil && user.isContact ||
[user.userID isEqualToString:[TAPDataManager getActiveUser].userID]
) {
// Hide if add to contacts menu is disabled in TapUI or user is already a contact
height = 0.0f;
}
}
else if (indexPath.row == 1) {
// Report user
if (![[TapUI sharedInstance] getReportButtonInChatProfileVisibleState]) {
height = 0.0f;
}
}
}
}
if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeGroupMemberProfile) {
TAPUserModel *user = [[TAPContactManager sharedManager] getUserWithUserID:self.user.userID];
if (indexPath.row == 0) {
......@@ -262,6 +285,12 @@
height = 0.0f;
}
}
else if (indexPath.row == 4) {
// Report member
if (![[TapUI sharedInstance] getReportButtonInChatProfileVisibleState]) {
height = 0.0f;
}
}
}
else if (self.tapProfileViewControllerType == TAPProfileViewControllerTypePersonalFromClickedMention) {
TAPUserModel *user = [[TAPContactManager sharedManager] getUserWithUserID:self.user.userID];
......@@ -276,6 +305,12 @@
height = 0.0f;
}
}
else if (indexPath.row == 1) {
// Report member
if (![[TapUI sharedInstance] getReportButtonInChatProfileVisibleState]) {
height = 0.0f;
}
}
}
CGSize cellSize = CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), height);
......@@ -339,17 +374,20 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeDefault) {
//DV Note
//Temporary Hidden For V1 because features is not complete (25 Mar 2019)
// return 4;
// return 5;
//END DV Note
if (self.room.type == RoomTypeGroup) {
if (self.room.type == RoomTypePersonal) {
return 2;
}
else if (self.room.type == RoomTypeGroup) {
return 3;
}
}
else if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeGroupMemberProfile) {
return 4; //add to contact, send message, appoint as admin, remove member
return 5; //add to contact, send message, appoint as admin, remove member, report
}
else if (self.tapProfileViewControllerType == TAPProfileViewControllerTypePersonalFromClickedMention) {
return 2; //add to contact, send message
return 3; //add to contact, send message, report
}
return 0;
}
......@@ -389,7 +427,22 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
//END DV Note
if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeDefault) {
if (self.room.type == RoomTypeGroup) {
if (self.room.type == RoomTypePersonal) {
NSString *cellID = @"TAPProfileCollectionViewCell";
[collectionView registerClass:[TAPProfileCollectionViewCell class] forCellWithReuseIdentifier:cellID];
TAPProfileCollectionViewCell *cell = (TAPProfileCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
if (indexPath.item == 0) {
//add contact
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeAddContacts];
[cell showSeparatorView:YES];
}
else if (indexPath.item == 1) {
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeReportUser];
[cell showSeparatorView:YES];
}
return cell;
}
else if (self.room.type == RoomTypeGroup) {
NSString *cellID = @"TAPProfileCollectionViewCell";
[collectionView registerClass:[TAPProfileCollectionViewCell class] forCellWithReuseIdentifier:cellID];
TAPProfileCollectionViewCell *cell = (TAPProfileCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
......@@ -409,6 +462,10 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
[cell showSeparatorView:YES];
}
else if (indexPath.item == 2) {
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeReportGroup];
[cell showSeparatorView:YES];
}
return cell;
}
......@@ -444,6 +501,10 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeRemoveMember];
[cell showSeparatorView:YES];
}
else if (indexPath.item == 4) {
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeReportUser];
[cell showSeparatorView:YES];
}
return cell;
}
......@@ -462,6 +523,10 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeSendMessage];
[cell showSeparatorView:YES];
}
else if (indexPath.item == 2) {
[cell setProfileCollectionViewCellType:profileCollectionViewCellTypeReportUser];
[cell showSeparatorView:YES];
}
return cell;
}
......@@ -645,7 +710,50 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeDefault) {
if (self.room.type == RoomTypeGroup) {
if (self.room.type == RoomTypePersonal) {
if (indexPath.row == 0) {
//add to contacts
[self.profileView showLoadingView:YES];
[self.profileView setAsLoadingState:YES withType:TAPProfileLoadingTypeAddToContact];
NSString *currentUserID = [TAPDataManager getActiveUser].userID;
currentUserID = [TAPUtil nullToEmptyString:currentUserID];
if ([currentUserID isEqualToString:self.user.userID]) {
//Add theirselves
[self removeLoadingView];
[self showPopupViewWithPopupType:TAPPopUpInfoViewControllerTypeErrorMessage popupIdentifier:@"Error Add User To Contact" title:NSLocalizedStringFromTableInBundle(@"Error", nil, [TAPUtil currentBundle], @"") detailInformation:NSLocalizedStringFromTableInBundle(@"Can't add yourself as contact", nil, [TAPUtil currentBundle], @"") leftOptionButtonTitle:nil singleOrRightOptionButtonTitle:nil];
}
else {
NSString *otherUserID = [[TAPChatManager sharedManager] getOtherUserIDWithRoomID:self.room.roomID];
TAPUserModel *obtainedUser = [[TAPContactManager sharedManager] getUserWithUserID:otherUserID];
[TAPDataManager callAPIAddContactWithUserID:obtainedUser.userID success:^(NSString *message, TAPUserModel *user) {
[[TAPContactManager sharedManager] addContactWithUserModel:user saveToDatabase:YES saveActiveUser:NO];
[self showFinishLoadingStateWithType:TAPProfileLoadingTypeAddToContact];
[TAPUtil performBlock:^{
[self.navigationController popViewControllerAnimated:YES];
} afterDelay:1.2f];
} failure:^(NSError *error) {
#ifdef DEBUG
NSLog(@"%@", error);
#endif
[self removeLoadingView];
}];
}
}
else if (indexPath.row == 1) {
// Report user
id <TapUIChatProfileDelegate> chatProfileDelegate = [TapUI sharedInstance].chatProfileDelegate;
if ([chatProfileDelegate respondsToSelector:@selector(reportUserButtonDidTapped:room:user:)]) {
NSString *otherUserID = [[TAPChatManager sharedManager] getOtherUserIDWithRoomID:self.room.roomID];
TAPUserModel *obtainedUser = [[TAPContactManager sharedManager] getUserWithUserID:otherUserID];
[chatProfileDelegate reportUserButtonDidTapped:self room:self.room user:obtainedUser];
}
}
}
else if (self.room.type == RoomTypeGroup) {
if (indexPath.row == 0) {
//view group members
_isLeaveFromGroupProfilePage = YES;
......@@ -667,6 +775,13 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
[self showPopupViewWithPopupType:TAPPopUpInfoViewControllerTypeInfoDestructive popupIdentifier:@"Leave Group" title:NSLocalizedStringFromTableInBundle(@"Leave Group", nil, [TAPUtil currentBundle], @"") detailInformation:NSLocalizedStringFromTableInBundle(@"All messages and shared medias from this room will be inaccessible. Are you sure you want to leave?", nil, [TAPUtil currentBundle], @"") leftOptionButtonTitle:NSLocalizedStringFromTableInBundle(@"Cancel", nil, [TAPUtil currentBundle], @"") singleOrRightOptionButtonTitle:NSLocalizedStringFromTableInBundle(@"Leave", nil, [TAPUtil currentBundle], @"")];
}
}
else if (indexPath.row == 2) {
// Report group
id <TapUIChatProfileDelegate> chatProfileDelegate = [TapUI sharedInstance].chatProfileDelegate;
if ([chatProfileDelegate respondsToSelector:@selector(reportGroupButtonDidTapped:room:)]) {
[chatProfileDelegate reportGroupButtonDidTapped:self room:self.room];
}
}
}
}
else if (self.tapProfileViewControllerType == TAPProfileViewControllerTypeGroupMemberProfile) {
......@@ -743,6 +858,13 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
//remove member
[self showPopupViewWithPopupType:TAPPopUpInfoViewControllerTypeInfoDestructive popupIdentifier:@"Remove Member" title:NSLocalizedStringFromTableInBundle(@"Remove Member", nil, [TAPUtil currentBundle], @"") detailInformation:NSLocalizedStringFromTableInBundle(@"Are you sure you want to remove this member?", nil, [TAPUtil currentBundle], @"") leftOptionButtonTitle:NSLocalizedStringFromTableInBundle(@"Cancel", nil, [TAPUtil currentBundle], @"") singleOrRightOptionButtonTitle:NSLocalizedStringFromTableInBundle(@"OK", nil, [TAPUtil currentBundle], @"")];
}
else if (indexPath.row == 4) {
// Report member
id <TapUIChatProfileDelegate> chatProfileDelegate = [TapUI sharedInstance].chatProfileDelegate;
if ([chatProfileDelegate respondsToSelector:@selector(reportUserButtonDidTapped:room:user:)]) {
[chatProfileDelegate reportUserButtonDidTapped:self room:self.room user:self.user];
}
}
}
else if (self.tapProfileViewControllerType == TAPProfileViewControllerTypePersonalFromClickedMention) {
if (indexPath.row == 0) {
......@@ -784,6 +906,15 @@ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
[[[TapUI sharedInstance] roomListViewController].navigationController pushViewController:chatViewController animated:YES];
}];
}
else if (indexPath.row == 2) {
// Report user
id <TapUIChatProfileDelegate> chatProfileDelegate = [TapUI sharedInstance].chatProfileDelegate;
if ([chatProfileDelegate respondsToSelector:@selector(reportUserButtonDidTapped:room:user:)]) {
NSString *otherUserID = [[TAPChatManager sharedManager] getOtherUserIDWithRoomID:self.room.roomID];
TAPUserModel *obtainedUser = [[TAPContactManager sharedManager] getUserWithUserID:otherUserID];
[chatProfileDelegate reportUserButtonDidTapped:self room:self.room user:obtainedUser];
}
}
}
}
else if (indexPath.section == 1) {
......
......@@ -7083,7 +7083,7 @@ typedef NS_ENUM(NSInteger, TopFloatingIndicatorViewType) {
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self checkAndShowInputAccessoryView];
[self showDeleteMessageActionWithMessageArray:@[message.messageID]];
[self showDeleteMessageActionWithMessageArray:@[message]];
}];
UIAlertAction *cancelAction = [UIAlertAction
......@@ -10397,15 +10397,16 @@ typedef NS_ENUM(NSInteger, TopFloatingIndicatorViewType) {
}
}
 
- (void)showDeleteMessageActionWithMessageArray:(NSString *)deletedMessageIDArray {
- (void)showDeleteMessageActionWithMessageArray:(NSArray<TAPMessageModel *> *)deletedMessageArray {
 
[self checkAndShowInputAccessoryView];
//Temporary delete for everyone
//Delete For Everyone
[TAPDataManager callAPIDeleteMessageWithMessageIDs:deletedMessageIDArray roomID:[TAPChatManager sharedManager].activeRoom.roomID isDeletedForEveryone:YES success:^(NSArray *deletedMessageIDArray) {
TAPMessageModel *message = [deletedMessageArray objectAtIndex:0];
[[TAPCoreMessageManager sharedManager] deleteMessage:message success:^{
} failure:^(NSError *error) {
} failure:^(NSError * _Nonnull error) {
[self showPopupViewWithPopupType:TAPPopUpInfoViewControllerTypeErrorMessage popupIdentifier:@"Error Delete Message" title:NSLocalizedStringFromTableInBundle(@"Sorry", nil, [TAPUtil currentBundle], @"") detailInformation:NSLocalizedStringFromTableInBundle(@"Failed to delete message, please try again.", nil, [TAPUtil currentBundle], @"") leftOptionButtonTitle:nil singleOrRightOptionButtonTitle:nil];
}];
......
......@@ -22,7 +22,9 @@ typedef NS_ENUM(NSInteger, TAPProfileCollectionViewCellType) {
profileCollectionViewCellTypeSendMessage = 9,
profileCollectionViewCellTypeAppointAsAdmin = 10,
profileCollectionViewCellTypeRemoveMember = 11,
profileCollectionViewCellTypeRemoveFromAdmin = 12
profileCollectionViewCellTypeRemoveFromAdmin = 12,
profileCollectionViewCellTypeReportUser = 13,
profileCollectionViewCellTypeReportGroup = 14,
};
@interface TAPProfileCollectionViewCell : TAPBaseCollectionViewCell
......
......@@ -228,6 +228,27 @@
self.switchButton.alpha = 0.0f;
self.rightIconImageView.alpha = 0.0f;
}
else if (type == profileCollectionViewCellTypeReportUser) {
[self.iconImageView setImage:[UIImage imageNamed:@"TAPIconFlag" inBundle:[TAPUtil currentBundle] compatibleWithTraitCollection:nil]];
self.iconImageView.image = [self.iconImageView.image setImageTintColor:[[TAPStyleManager sharedManager] getComponentColorForType:TAPComponentColorIconGroupMemberProfileMenuReportUserOrGroup]];
self.titleLabel.textColor = titleLabelDestructiveColor;
self.titleLabel.text = NSLocalizedStringFromTableInBundle(@"Report User", nil, [TAPUtil currentBundle], @"");
self.switchButton.alpha = 0.0f;
self.rightIconImageView.alpha = 0.0f;
}
else if (type == profileCollectionViewCellTypeReportGroup) {
[self.iconImageView setImage:[UIImage imageNamed:@"TAPIconFlag" inBundle:[TAPUtil currentBundle] compatibleWithTraitCollection:nil]];
self.iconImageView.image = [self.iconImageView.image setImageTintColor:[[TAPStyleManager sharedManager] getComponentColorForType:TAPComponentColorIconGroupMemberProfileMenuReportUserOrGroup]];
self.titleLabel.textColor = titleLabelDestructiveColor;
self.titleLabel.text = NSLocalizedStringFromTableInBundle(@"Report Group", nil, [TAPUtil currentBundle], @"");
self.switchButton.alpha = 0.0f;
self.rightIconImageView.alpha = 0.0f;
}
}
- (void)switchValueChanged:(id)sender {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment