diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 83c1c8e88..32f1394f1 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -1122,7 +1122,7 @@ uint32_t p3MsgService::sendMessage(RsMsgItem* item) IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST, NOTIFY_TYPE_ADD); + RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST, NOTIFY_TYPE_ADD); // deprecated return item->msgId; } @@ -1196,10 +1196,15 @@ bool p3MsgService::MessageSend(MessageInfo &info) info.msgId = std::to_string(msg->msgId); info .msgflags = msg->msgFlags; - RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD); + RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);// deprecated. Should be removed. Oct. 28, 2020 } - return true; + auto pEvent = std::make_shared(); + pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT; + pEvent->mChangedMsgIds.insert(std::to_string(msg->msgId)); + rsEvents->postEvent(pEvent); + + return true; } uint32_t p3MsgService::sendMail( @@ -1399,7 +1404,11 @@ bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParen IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); + // RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); + + auto pEvent = std::make_shared(); + pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT; + rsEvents->postEvent(pEvent); return true; } diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 93d59a28e..9562453ae 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -877,7 +877,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) sync_string = tr("Unknown"); } - if(group.mMeta.mLastPost + rsPosted->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + if(group.mMeta.mLastPost > 0 && group.mMeta.mLastPost + rsPosted->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) sync_string += " (Warning: will not allow latest posts to sync)"; ui->syncPeriodLabel->setText(sync_string); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 1e0c676b7..e03c41c32 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -1093,7 +1093,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou sync_string = tr("Unknown"); } - if(group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) + if(group.mMeta.mLastPost > 0 && group.mMeta.mLastPost + rsGxsChannels->getSyncPeriod(group.mMeta.mGroupId) < time(NULL) && IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) sync_string += " (Warning: will not allow latest posts to sync)"; ui->infoSyncTimeLabel->setText(sync_string); @@ -1185,13 +1185,13 @@ void GxsChannelPostsWidgetWithModel::setSubscribeButtonText(const RsGxsGroupId& ui->subscribeToolButton->setEnabled(true); break; case DistantSearchGroupStatus::CAN_BE_REQUESTED: // means no search ongoing. This is not a distant search - ui->subscribeToolButton->setText(tr("Request data")); + ui->subscribeToolButton->setText(tr("Subscribe")); ui->subscribeToolButton->setToolTip(tr("Hit this button to retrieve the data you need to subscribe to this channel") ); ui->subscribeToolButton->setSubscribed(false); ui->subscribeToolButton->setEnabled(false); break; case DistantSearchGroupStatus::ONGOING_REQUEST: - ui->subscribeToolButton->setText(tr("Ongoing request...")); + ui->subscribeToolButton->setText(tr("Subscribe")); ui->subscribeToolButton->setToolTip(""); ui->subscribeToolButton->setSubscribed(true); ui->subscribeToolButton->setEnabled(false); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index db3083686..341e87326 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1427,7 +1427,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) break ; default: - std::cerr << __PRETTY_FUNCTION__ << ": Unhandled desitnation type " << dtype << std::endl; + std::cerr << __PRETTY_FUNCTION__ << ": Unhandled destination type " << dtype << std::endl; break ; } } diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index acb19d900..5d6788eb9 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -284,6 +284,30 @@ MessagesDialog::MessagesDialog(QWidget *parent) connect(ui.messageTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumn(int,Qt::SortOrder))); connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&,const QModelIndex&))); + + mEventHandlerId=0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::MAIL_STATUS ); +} + +void MessagesDialog::handleEvent(std::shared_ptr event) +{ + if(event->mType != RsEventType::MAIL_STATUS) + return; + + const RsMailStatusEvent *fe = dynamic_cast(event.get()); + if(!fe) + return; + + switch (fe->mMailStatusEventCode) + { + case RsMailStatusEventCode::MESSAGE_SENT: + case RsMailStatusEventCode::MESSAGE_REMOVED: + case RsMailStatusEventCode::NEW_MESSAGE: + updateMessageSummaryList(); + break; + default: + break; + } } void MessagesDialog::preModelUpdate() @@ -836,6 +860,8 @@ void MessagesDialog::changeBox(int box_row) mMessageModel->setCurrentBox(RsMessageModel::BOX_NONE); } inChange = false; + + updateMessageSummaryList(); } void MessagesDialog::changeQuickView(int newrow) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index bf0148cf5..df8513d18 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -23,6 +23,7 @@ #include +#include #include #include "ui_MessagesDialog.h" @@ -110,6 +111,8 @@ private slots: void tabCloseRequested(int tab); private: + void handleEvent(std::shared_ptr event); + void updateInterface(); void connectActions(); @@ -157,6 +160,8 @@ private: QList mTmpSavedSelectedIds; QModelIndex lastSelectedIndex; + + RsEventsHandlerId_t mEventHandlerId; }; #endif