Fix compatibility with newer quotient job api
This commit is contained in:
@@ -163,7 +163,11 @@ void AccountEmoticonModel::setEmoticonImage(int index, const QUrl &source)
|
||||
QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl source)
|
||||
{
|
||||
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
co_await qCoro(job.get(), &BaseJob::finished);
|
||||
#else
|
||||
co_await qCoro(job, &BaseJob::finished);
|
||||
#endif
|
||||
if (job->error() != BaseJob::NoError) {
|
||||
co_return;
|
||||
}
|
||||
@@ -185,7 +189,11 @@ QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl sourc
|
||||
QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString shortcode, QString description, QString type)
|
||||
{
|
||||
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
co_await qCoro(job.get(), &BaseJob::finished);
|
||||
#else
|
||||
co_await qCoro(job, &BaseJob::finished);
|
||||
#endif
|
||||
if (job->error() != BaseJob::NoError) {
|
||||
co_return;
|
||||
}
|
||||
|
||||
@@ -128,8 +128,12 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
||||
authData["type"_ls] = "m.login.password"_ls;
|
||||
QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}};
|
||||
authData["identifier"_ls] = identifier;
|
||||
auto *innerJob = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId, authData);
|
||||
auto innerJob = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId, authData);
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
connect(innerJob.get(), &BaseJob::success, this, onSuccess);
|
||||
#else
|
||||
connect(innerJob, &BaseJob::success, this, onSuccess);
|
||||
#endif
|
||||
} else {
|
||||
onSuccess();
|
||||
}
|
||||
|
||||
@@ -1156,7 +1156,11 @@ QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user, QStri
|
||||
}
|
||||
for (const auto &e : events) {
|
||||
auto job = connection()->callApi<RedactEventJob>(id(), QString::fromLatin1(QUrl::toPercentEncoding(e)), connection()->generateTxnId(), reason);
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
co_await qCoro(job.get(), &BaseJob::finished);
|
||||
#else
|
||||
co_await qCoro(job, &BaseJob::finished);
|
||||
#endif
|
||||
if (job->error() != BaseJob::Success) {
|
||||
qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting";
|
||||
break;
|
||||
|
||||
@@ -301,7 +301,11 @@ void RoomManager::visitRoom(Room *r, const QString &eventId)
|
||||
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
||||
{
|
||||
auto job = account->joinRoom(roomAliasOrId, viaServers);
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
connectSingleShot(job.get(), &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) {
|
||||
#else
|
||||
connectSingleShot(job, &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) {
|
||||
#endif
|
||||
if (finish->status() == Quotient::BaseJob::Success) {
|
||||
connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) {
|
||||
resolveResource(room->id());
|
||||
@@ -314,12 +318,16 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli
|
||||
|
||||
void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers)
|
||||
{
|
||||
auto *const job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, reason);
|
||||
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, reason);
|
||||
// Upon completion, ensure a room object is created in case it hasn't come
|
||||
// with a sync yet. If the room object is not there, provideRoom() will
|
||||
// create it in Join state. finished() is used here instead of success()
|
||||
// to overtake clients that may add their own slots to finished().
|
||||
#if Quotient_VERSION_MINOR > 8
|
||||
connectSingleShot(job.get(), &BaseJob::finished, this, [this, job, account] {
|
||||
#else
|
||||
connectSingleShot(job, &BaseJob::finished, this, [this, job, account] {
|
||||
#endif
|
||||
if (job->status() == Quotient::BaseJob::Success) {
|
||||
connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) {
|
||||
Q_EMIT currentRoom()->showMessage(NeoChatRoom::Info, i18n("You requested to join '%1'", room->name()));
|
||||
|
||||
Reference in New Issue
Block a user