fix index issue in data base

This commit is contained in:
Benjamin Reis 2017-11-27 11:55:51 +01:00
parent a6b6b7aeb4
commit 81ff3c8813
3 changed files with 10 additions and 10 deletions

View file

@ -218,7 +218,10 @@ bctbx_list_t *linphone_chat_room_get_history_range_events (LinphoneChatRoom *cr,
}
LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastMessageInHistory());
shared_ptr<LinphonePrivate::ChatMessage> cppPtr = L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getLastMessageInHistory();
LinphoneChatMessage *object = L_INIT(ChatMessage);
L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr);
return object;
}
LinphoneChatMessage *linphone_chat_room_find_message (LinphoneChatRoom *cr, const char *message_id) {

View file

@ -1391,19 +1391,16 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
return list<shared_ptr<ChatMessage>>();
}
shared_ptr<ChatMessage> MainDb::getLastChatMessage(const ChatRoomId &chatRoomId) const {
list<shared_ptr<EventLog>> chatList = getHistory (chatRoomId, 1, Filter::ConferenceChatMessageFilter);
if (chatList.size() == 0)
shared_ptr<ChatMessage> MainDb::getLastChatMessage (const ChatRoomId &chatRoomId) const {
list<shared_ptr<EventLog>> chatList = getHistory(chatRoomId, 1, Filter::ConferenceChatMessageFilter);
if (chatList.empty())
return nullptr;
L_ASSERT(chatList.size() == 1);
shared_ptr<EventLog> chatEvent = chatList.front();
L_ASSERT(chatEvent->getType() == EventLog::Type::ConferenceChatMessage);
return static_pointer_cast<ConferenceChatMessageEvent>(chatEvent)->getChatMessage();
return static_pointer_cast<ConferenceChatMessageEvent>(chatList.front())->getChatMessage();
}
list<shared_ptr<EventLog>> MainDb::getHistory (const ChatRoomId &chatRoomId, int nLast, FilterMask mask) const {
return getHistoryRange(chatRoomId, 0, nLast - 1, mask);
return getHistoryRange(chatRoomId, 0, nLast, mask);
}
list<shared_ptr<EventLog>> MainDb::getHistoryRange (

View file

@ -77,7 +77,7 @@ public:
int getUnreadChatMessagesCount (const ChatRoomId &chatRoomId = ChatRoomId()) const;
void markChatMessagesAsRead (const ChatRoomId &chatRoomId = ChatRoomId()) const;
std::list<std::shared_ptr<ChatMessage>> getUnreadChatMessages (const ChatRoomId &chatRoomId = ChatRoomId()) const;
std::shared_ptr<ChatMessage> getLastChatMessage(const ChatRoomId &chatRoomId = ChatRoomId()) const;
std::shared_ptr<ChatMessage> getLastChatMessage (const ChatRoomId &chatRoomId = ChatRoomId()) const;
// ---------------------------------------------------------------------------
// Conference events.