ChatRoomViewController.m: call linphone_send_message only after having added the message to the list to avoid error log

This commit is contained in:
Gautier Pelloux-Prayer 2015-09-21 10:47:00 +02:00
parent 35c7325892
commit 50ad17e7bc
3 changed files with 12 additions and 4 deletions

View file

@ -278,8 +278,6 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
linphone_chat_message_set_external_body_url(msg, [[externalUrl absoluteString] UTF8String]);
}
linphone_chat_room_send_message2(chatRoom, msg, message_status, (__bridge void *)(self));
if (internalUrl) {
// internal url is saved in the appdata for display and later save
[LinphoneManager setValueInMessageAppData:[internalUrl absoluteString] forKey:@"localimage" inMessage:msg];
@ -287,6 +285,9 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
[tableController addChatEntry:msg];
[tableController scrollToBottom:true];
linphone_chat_room_send_message2(chatRoom, msg, message_status, (__bridge void *)(self));
return TRUE;
}

View file

@ -453,7 +453,6 @@ static UIFont *CELL_FONT = nil;
#pragma mark - State changed handling
static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
UIChatRoomCell *thiz = (__bridge UIChatRoomCell *)linphone_chat_message_get_user_data(msg);
LOGI(@"State for message [%p] changed to %s", msg, linphone_chat_message_state_to_string(state));
if (linphone_chat_message_get_file_transfer_information(msg) != NULL) {
if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
// we need to refresh the tableview because the filetransfer delegate unreffed
@ -470,8 +469,9 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
// This is breaking interface too much, it must be fixed in file transfer cb.. meanwhile, disabling it.
if (thiz->ftd) {
[thiz->ftd stopAndDestroy];
FileTransferDelegate *c = thiz->ftd;
thiz->ftd = nil;
[c stopAndDestroy];
}
}
}

View file

@ -321,6 +321,13 @@
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
}
- (void)testTransferDestroyRoomWhileUploading {
[self startChatWith:[self me]];
[self uploadImageWithQuality:@"Maximum"];
[self goBackFromChat];
[self removeAllRooms];
}
- (void)testTransferDownloadImage {
[self downloadImage];
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Cancel transfer"];