Merge pull request #2900 from csoler/v0.6-BugFixing_40

fixed bug causing own identity to not disappear when deleted
This commit is contained in:
csoler 2024-12-30 14:15:57 +01:00 committed by GitHub
commit 8d96bb920d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -429,6 +429,14 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
switch(e->mIdentityEventCode) switch(e->mIdentityEventCode)
{ {
case RsGxsIdentityEventCode::DELETED_IDENTITY: case RsGxsIdentityEventCode::DELETED_IDENTITY:
if(mId == e->mIdentityId)
{
mId.clear();
updateIdentity();
}
updateIdList();
break;
case RsGxsIdentityEventCode::NEW_IDENTITY: case RsGxsIdentityEventCode::NEW_IDENTITY:
case RsGxsIdentityEventCode::UPDATED_IDENTITY: case RsGxsIdentityEventCode::UPDATED_IDENTITY:
if (isVisible()) if (isVisible())
@ -436,7 +444,8 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
if(rsIdentity->isOwnId(RsGxsId(e->mIdentityId))) if(rsIdentity->isOwnId(RsGxsId(e->mIdentityId)))
updateIdList(); updateIdList();
else else
updateIdTimer.start(3000); // use a timer for events not generated by local changes updateIdTimer.start(3000); // use a timer for events not generated by local changes which generally
// come in large herds. Allows to group multiple changes into a single UI update.
} }
else else
needUpdateIdsOnNextShow = true; needUpdateIdsOnNextShow = true;
@ -1330,6 +1339,7 @@ void IdDialog::updateSelection()
void IdDialog::updateIdList() void IdDialog::updateIdList()
{ {
//int accept = filter; //int accept = filter;
std::cerr << "Updating ID list" << std::endl;
RsThread::async([this]() RsThread::async([this]()
{ {
@ -1512,6 +1522,8 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
{ {
auto ids_set(ids_set_const); auto ids_set(ids_set_const);
std::cerr << "Loading ID list" << std::endl;
//First: Get current item to restore after //First: Get current item to restore after
RsGxsGroupId oldCurrentId = mIdToNavigate; RsGxsGroupId oldCurrentId = mIdToNavigate;
{ {
@ -1598,9 +1610,9 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
int allCount = allItem->childCount() ; int allCount = allItem->childCount() ;
int ownCount = ownItem->childCount(); int ownCount = ownItem->childCount();
contactsItem->setText(0, tr("My contacts") + " (" + QString::number( contactsCount ) + ")" ); contactsItem->setText(0, tr("My contacts") + ((contactsCount>0)?" (" + QString::number( contactsCount ) + ")":"") );
allItem->setText(0, tr("All") + " (" + QString::number( allCount ) + ")" ); allItem->setText(0, tr("All") + ((allCount>0)?" (" + QString::number( allCount ) + ")":"") );
ownItem->setText(0, tr("My own identities") + " (" + QString::number( ownCount ) + ")" ); ownItem->setText(0, tr("My own identities") + ((ownCount>0)?" (" + QString::number( ownCount ) + ")":"") );
//Restore expanding //Restore expanding
@ -2086,14 +2098,12 @@ void IdDialog::removeIdentity()
return; return;
} }
if ((QMessageBox::question(this, tr("Really delete?"), tr("Do you really want to delete this identity?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No))== QMessageBox::Yes) if ((QMessageBox::question(this, tr("Really delete?"), tr("Do you really want to delete this identity?\nThis cannot be undone."), QMessageBox::Yes|QMessageBox::No, QMessageBox::No))== QMessageBox::Yes)
{ {
std::string keyId = item->text(RSID_COL_KEYID).toStdString(); std::string keyId = item->text(RSID_COL_KEYID).toStdString();
RsGxsId kid(keyId);
uint32_t dummyToken = 0; rsIdentity->deleteIdentity(kid);
RsGxsIdGroup group;
group.mMeta.mGroupId=RsGxsGroupId(keyId);
rsIdentity->deleteIdentity(dummyToken, group);
} }
} }