Fixed appearance of wraith-thread after new draft message 10/65610/4 accepted/tizen/mobile/20160413.074557 submit/tizen/20160412.093637
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 11 Apr 2016 15:16:37 +0000 (18:16 +0300)
committerAndrey Klimenko <and.klimenko@samsung.com>
Tue, 12 Apr 2016 08:38:42 +0000 (01:38 -0700)
Change-Id: Ie3df01e4019f7329adddf72086972a606fccfcae
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/MsgThread/Controller/inc/ThreadList.h
src/MsgThread/Controller/src/ThreadList.cpp

index a555170..fcd57f8 100644 (file)
@@ -76,6 +76,7 @@ namespace Msg
             void updateItems();
             void insertItem(const MsgThreadItem &msgThreadItem);
             void insertItem(ThreadId id);
+            ThreadListItem *getItem(ThreadId id) const;
             bool isAllThreadListItemChecked() const;
             void updateSelectAllItem();
             std::set<ThreadId> getThreadIdSet(const MsgIdList &idList);
index 0925169..e32137d 100644 (file)
@@ -200,6 +200,17 @@ void ThreadList::insertItem(ThreadId id)
         insertItem(*threadItem);
 }
 
+ThreadListItem *ThreadList::getItem(ThreadId id) const
+{
+    auto items = ListView::getItems<ThreadListItem>();
+    for(ThreadListItem *item : items)
+    {
+        if(item->getThreadId() == id)
+            return item;
+    }
+    return nullptr;
+}
+
 void ThreadList::fillList()
 {
     MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList();
@@ -303,13 +314,30 @@ void ThreadList::onMsgStorageUpdate(const MsgIdList &msgIdList)
 void ThreadList::onMsgStorageInsert(const MsgIdList &msgIdList)
 {
     MSG_LOG("");
+
+    bool inserted = false;
+    bool updated = false;
+
     auto threadSet = getThreadIdSet(msgIdList);
     for(ThreadId id : threadSet)
     {
-        insertItem(id);
+        ThreadListItem *item = getItem(id);
+        if(item)
+        {
+            item->update();
+            updated = true;
+        }
+        else
+        {
+            insertItem(id);
+            inserted = true;
+        }
     }
 
-    updateSelectAllItem();
+    if(inserted)
+        updateSelectAllItem();
+    if(updated)
+        updateRealizedItems();
 
     if(m_pListener)
         m_pListener->onThreadListChanged();