fix can not send message in one-to-one chatroom when has been left

This commit is contained in:
Danmei Chen 2020-02-28 13:28:22 +01:00
parent 6e1904e9f5
commit 59e4034633
2 changed files with 19 additions and 7 deletions

View file

@ -103,6 +103,7 @@
- (void)update; - (void)update;
- (void)openFileWithURL:(NSURL *)url; - (void)openFileWithURL:(NSURL *)url;
- (void)clearMessageView; - (void)clearMessageView;
- (void)configureMessageField;
- (void)showFileDownloadError; - (void)showFileDownloadError;
- (NSURL *)getICloudFileUrl:(NSString *)name; - (NSURL *)getICloudFileUrl:(NSString *)name;

View file

@ -269,10 +269,7 @@ static UICompositeViewDescription *compositeDescription = nil;
_addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT]; _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT];
[self updateParticipantLabel]; [self updateParticipantLabel];
[self configureMessageField];
_messageField.editable = !linphone_chat_room_has_been_left(_chatRoom);
_pictureButton.enabled = !linphone_chat_room_has_been_left(_chatRoom);
_messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(_chatRoom);
[_tableController setChatRoom:_chatRoom]; [_tableController setChatRoom:_chatRoom];
_chatView.hidden = NO; _chatView.hidden = NO;
@ -283,6 +280,22 @@ static UICompositeViewDescription *compositeDescription = nil;
[self shareFile]; [self shareFile];
} }
- (void)configureMessageField {
LinphoneChatRoomCapabilitiesMask capabilities = linphone_chat_room_get_capabilities(_chatRoom);
if (capabilities & LinphoneChatRoomCapabilitiesOneToOne) {
_messageField.editable = TRUE;
_pictureButton.enabled = TRUE;
_messageView.userInteractionEnabled = TRUE;
if (linphone_chat_room_has_been_left(_chatRoom)) {
linphone_chat_room_add_participant(_chatRoom, linphone_participant_get_address(linphone_chat_room_get_me(_chatRoom)));
}
} else {
_messageField.editable = !linphone_chat_room_has_been_left(_chatRoom);
_pictureButton.enabled = !linphone_chat_room_has_been_left(_chatRoom);
_messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(_chatRoom);
}
}
- (void)shareFile { - (void)shareFile {
NSString* groupName = [NSString stringWithFormat:@"group.%@.linphoneExtension",[[NSBundle mainBundle] bundleIdentifier]]; NSString* groupName = [NSString stringWithFormat:@"group.%@.linphoneExtension",[[NSBundle mainBundle] bundleIdentifier]];
@ -999,9 +1012,7 @@ static UICompositeViewDescription *compositeDescription = nil;
void on_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) { void on_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
ChatConversationView *view = (__bridge ChatConversationView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_current_callbacks(cr)); ChatConversationView *view = (__bridge ChatConversationView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_current_callbacks(cr));
view.messageField.editable = !linphone_chat_room_has_been_left(cr); [view configureMessageField];
view.pictureButton.enabled = !linphone_chat_room_has_been_left(cr);
view.messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(cr);
} }
void on_chat_room_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) { void on_chat_room_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {