diff --git a/libretroshare/src/pqi/p3historymgr.cc b/libretroshare/src/pqi/p3historymgr.cc index b384964aa..01d365b4b 100644 --- a/libretroshare/src/pqi/p3historymgr.cc +++ b/libretroshare/src/pqi/p3historymgr.cc @@ -63,16 +63,15 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons return; } - if (mPrivateEnable == false && chatPeerId.empty() == false) { - // private chat not enabled - return; - } - const RsChatLobbyMsgItem *cli = dynamic_cast(chatItem); if (cli) { - // disable history for chat lobbies until they are saved - return; + // there is currently no setting for chat lobbies + } else { + if (mPrivateEnable == false && chatPeerId.empty() == false) { + // private chat not enabled + return; + } } RsHistoryMsgItem* item = new RsHistoryMsgItem; @@ -83,6 +82,11 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons item->sendTime = chatItem->sendTime; item->recvTime = chatItem->recvTime; + if (cli) { + // disable save to disc for chat lobbies until they are saved + item->saveToDisc = false; + } + librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message); std::map >::iterator mit = mMessages.find(item->chatPeerId); @@ -96,7 +100,12 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons if (chatPeerId.empty()) { limit = mPublicSaveCount; } else { - limit = mPrivateSaveCount; + if (cli) { + // there is currently no setting for chat lobbies + limit = 0; + } else { + limit = mPrivateSaveCount; + } } if (limit) { @@ -144,7 +153,9 @@ bool p3HistoryMgr::saveList(bool& cleanup, std::list& saveData) std::map::iterator lit; for (mit = mMessages.begin(); mit != mMessages.end(); mit++) { for (lit = mit->second.begin(); lit != mit->second.end(); lit++) { - saveData.push_back(lit->second); + if (lit->second->saveToDisc) { + saveData.push_back(lit->second); + } } } diff --git a/libretroshare/src/serialiser/rshistoryitems.cc b/libretroshare/src/serialiser/rshistoryitems.cc index a4c9be002..0cb270ad3 100644 --- a/libretroshare/src/serialiser/rshistoryitems.cc +++ b/libretroshare/src/serialiser/rshistoryitems.cc @@ -42,6 +42,7 @@ RsHistoryMsgItem::RsHistoryMsgItem() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONF sendTime = 0; recvTime = 0; msgId = 0; + saveToDisc = true; } RsHistoryMsgItem::~RsHistoryMsgItem() @@ -57,6 +58,7 @@ void RsHistoryMsgItem::clear() recvTime = 0; message.clear(); msgId = 0; + saveToDisc = true; } std::ostream& RsHistoryMsgItem::print(std::ostream &out, uint16_t indent) diff --git a/libretroshare/src/serialiser/rshistoryitems.h b/libretroshare/src/serialiser/rshistoryitems.h index 617c43ecf..fb194d8fa 100644 --- a/libretroshare/src/serialiser/rshistoryitems.h +++ b/libretroshare/src/serialiser/rshistoryitems.h @@ -50,6 +50,7 @@ public: /* not serialised */ uint32_t msgId; + bool saveToDisc; }; class RsHistorySerialiser: public RsSerialType diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index ad6bf02bf..6cea4151d 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -183,10 +183,6 @@ void ChatWidget::init(const std::string &peerId, const QString &title) QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(peerId).c_str()); updatePeersCustomStateString(QString::fromStdString(peerId), customStateString); } else { - // currently not possible - ui->actionDeleteChatHistory->setVisible(false); - ui->actionMessageHistory->setVisible(false); - updateTitle(); }