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)
|
QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl source)
|
||||||
{
|
{
|
||||||
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
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);
|
co_await qCoro(job, &BaseJob::finished);
|
||||||
|
#endif
|
||||||
if (job->error() != BaseJob::NoError) {
|
if (job->error() != BaseJob::NoError) {
|
||||||
co_return;
|
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)
|
QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString shortcode, QString description, QString type)
|
||||||
{
|
{
|
||||||
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
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);
|
co_await qCoro(job, &BaseJob::finished);
|
||||||
|
#endif
|
||||||
if (job->error() != BaseJob::NoError) {
|
if (job->error() != BaseJob::NoError) {
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,8 +128,12 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
|||||||
authData["type"_ls] = "m.login.password"_ls;
|
authData["type"_ls] = "m.login.password"_ls;
|
||||||
QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}};
|
QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}};
|
||||||
authData["identifier"_ls] = identifier;
|
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);
|
connect(innerJob, &BaseJob::success, this, onSuccess);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1156,7 +1156,11 @@ QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user, QStri
|
|||||||
}
|
}
|
||||||
for (const auto &e : events) {
|
for (const auto &e : events) {
|
||||||
auto job = connection()->callApi<RedactEventJob>(id(), QString::fromLatin1(QUrl::toPercentEncoding(e)), connection()->generateTxnId(), reason);
|
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);
|
co_await qCoro(job, &BaseJob::finished);
|
||||||
|
#endif
|
||||||
if (job->error() != BaseJob::Success) {
|
if (job->error() != BaseJob::Success) {
|
||||||
qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting";
|
qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting";
|
||||||
break;
|
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)
|
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
||||||
{
|
{
|
||||||
auto job = account->joinRoom(roomAliasOrId, 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) {
|
connectSingleShot(job, &Quotient::BaseJob::finished, this, [this, account](Quotient::BaseJob *finish) {
|
||||||
|
#endif
|
||||||
if (finish->status() == Quotient::BaseJob::Success) {
|
if (finish->status() == Quotient::BaseJob::Success) {
|
||||||
connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) {
|
connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) {
|
||||||
resolveResource(room->id());
|
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)
|
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
|
// 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
|
// 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()
|
// create it in Join state. finished() is used here instead of success()
|
||||||
// to overtake clients that may add their own slots to finished().
|
// 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] {
|
connectSingleShot(job, &BaseJob::finished, this, [this, job, account] {
|
||||||
|
#endif
|
||||||
if (job->status() == Quotient::BaseJob::Success) {
|
if (job->status() == Quotient::BaseJob::Success) {
|
||||||
connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) {
|
connectSingleShot(account, &NeoChatConnection::newRoom, this, [this](Quotient::Room *room) {
|
||||||
Q_EMIT currentRoom()->showMessage(NeoChatRoom::Info, i18n("You requested to join '%1'", room->name()));
|
Q_EMIT currentRoom()->showMessage(NeoChatRoom::Info, i18n("You requested to join '%1'", room->name()));
|
||||||
|
|||||||
Reference in New Issue
Block a user