fixed missed notification in Messages when new/draft msg happens by switching to new event system

This commit is contained in:
csoler 2020-10-28 21:26:07 +01:00
parent b74e6dbe42
commit b5cfa46073
6 changed files with 49 additions and 9 deletions

View File

@ -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,9 +1196,14 @@ 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
}
auto pEvent = std::make_shared<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
pEvent->mChangedMsgIds.insert(std::to_string(msg->msgId));
rsEvents->postEvent(pEvent);
return true;
}
@ -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<RsMailStatusEvent>();
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
rsEvents->postEvent(pEvent);
return true;
}

View File

@ -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);

View File

@ -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);

View File

@ -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 ;
}
}

View File

@ -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<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::MAIL_STATUS );
}
void MessagesDialog::handleEvent(std::shared_ptr<const RsEvent> event)
{
if(event->mType != RsEventType::MAIL_STATUS)
return;
const RsMailStatusEvent *fe = dynamic_cast<const RsMailStatusEvent*>(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)

View File

@ -23,6 +23,7 @@
#include <QSortFilterProxyModel>
#include <retroshare/rsevents.h>
#include <retroshare-gui/mainpage.h>
#include "ui_MessagesDialog.h"
@ -110,6 +111,8 @@ private slots:
void tabCloseRequested(int tab);
private:
void handleEvent(std::shared_ptr<const RsEvent> event);
void updateInterface();
void connectActions();
@ -157,6 +160,8 @@ private:
QList<QString> mTmpSavedSelectedIds;
QModelIndex lastSelectedIndex;
RsEventsHandlerId_t mEventHandlerId;
};
#endif