Skip to content

Commit

Permalink
MixManager: Use new 'transform()'
Browse files Browse the repository at this point in the history
  • Loading branch information
melvo committed Mar 22, 2024
1 parent 526676f commit 5fc73aa
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/client/QXmppMixManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "QXmppRosterManager.h"
#include "QXmppUtils.h"

#include "Algorithms.h"

#include <QDomElement>
#include <QStringBuilder>

Expand Down Expand Up @@ -431,15 +433,11 @@ QXmppTask<QXmppMixManager::ChannelJidResult> QXmppMixManager::requestChannelJids
{
return chain<ChannelJidResult>(d->discoveryManager->requestDiscoItems(serviceJid), this, [](QXmppDiscoveryManager::ItemsResult &&result) -> ChannelJidResult {
if (const auto items = std::get_if<QList<QXmppDiscoveryIq::Item>>(&result)) {
QVector<ChannelJid> jids;

std::for_each(items->cbegin(), items->cend(), [&jids](const QXmppDiscoveryIq::Item &item) {
jids.append(item.jid());
return transform<QVector<ChannelJid>>(*items, [](const QXmppDiscoveryIq::Item &item) {
return item.jid();
});

return std::move(jids);
} else {
return std::move(std::get<QXmppError>(result));
return std::get<QXmppError>(std::move(result));
}
});
}
Expand All @@ -458,9 +456,8 @@ QXmppTask<QXmppMixManager::ChannelNodeResult> QXmppMixManager::requestChannelNod
return std::move(*error);
} else {
const auto &items = std::get<QList<QXmppDiscoveryIq::Item>>(result);
QVector<QString> nodes(items.size());

std::transform(items.cbegin(), items.cend(), nodes.begin(), [](const QXmppDiscoveryIq::Item &item) {
const auto nodes = transform<QVector<QString>>(items, [](const QXmppDiscoveryIq::Item &item) {
return item.node();
});

Expand Down Expand Up @@ -1204,13 +1201,9 @@ QXmppTask<QXmppMixManager::JidResult> QXmppMixManager::requestJids(const QString
return std::move(*error);
} else {
const auto &items = std::get<QXmppPubSubManager::Items<QXmppPubSubBaseItem>>(result).items;
QVector<Jid> jids;

std::for_each(items.cbegin(), items.cend(), [&jids](const QXmppPubSubBaseItem &item) mutable {
jids.append(item.id());
return transform<QVector<Jid>>(items, [](const QXmppPubSubBaseItem &item) {
return item.id();
});

return std::move(jids);
}
});
}
Expand Down

0 comments on commit 5fc73aa

Please sign in to comment.