From 2af66e91c53927fc9d5fd95b44e3bcc0718e0b84 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Oct 2020 21:47:00 +0200 Subject: [PATCH] fixed closing of comments tab when comments update --- .../gui/Posted/PostedListWidgetWithModel.cpp | 22 +++++++++++++++---- retroshare-gui/src/gui/gxs/GxsCommentDialog.h | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 4bf36f218..d0cb983a7 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -432,9 +432,20 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptrmPostedEventCode) { - case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; + case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; + { + // special treatment here because the message might be a comment, so we need to refresh the comment tab if openned + + for(int i=2;itabWidget->count();++i) + { + auto *t = dynamic_cast(ui->tabWidget->widget(i)); + + if(t->groupId() == e->mPostedGroupId) + t->refresh(); + } + } + case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]]; case RsPostedEventCode::UPDATED_POSTED_GROUP: // [[fallthrough]]; - case RsPostedEventCode::NEW_MESSAGE: // [[fallthrough]]; case RsPostedEventCode::UPDATED_MESSAGE: { if(e->mPostedGroupId == groupId()) @@ -550,13 +561,16 @@ void PostedListWidgetWithModel::updateGroupData() RsQThreadUtils::postToObject( [this,groups]() { + bool group_changed = (groups[0].mMeta.mGroupId!=mGroup.mMeta.mGroupId); + mGroup = groups[0]; mPostedPostsModel->updateBoard(groupId()); insertBoardDetails(mGroup); - while(ui->tabWidget->widget(2) != nullptr) - tabCloseRequested(2); + if(group_changed) + while(ui->tabWidget->widget(2) != nullptr) + tabCloseRequested(2); emit groupDataLoaded(); emit groupChanged(this); // signals the parent widget to e.g. update the group tab name diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h index 80a58ff47..987fd0c07 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h @@ -43,8 +43,10 @@ public: RsGxsGroupId groupId() { return mGrpId; } RsGxsMessageId messageId() { return mMostRecentMsgId; } +public slots: + void refresh(); + private slots: - void refresh(); void idChooserReady(); void voterSelectionChanged( int index ); void sortComments(int);