Re-run clang-format
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <csapi/account-data.h>
|
||||
#include <csapi/profile.h>
|
||||
#include <csapi/content-repo.h>
|
||||
#include <csapi/profile.h>
|
||||
|
||||
#include "customemojimodel_p.h"
|
||||
|
||||
@@ -19,16 +19,16 @@ void CustomEmojiModel::fetchEmojies()
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& data = d->conn->accountData("im.ponies.user_emotes");
|
||||
const auto &data = d->conn->accountData("im.ponies.user_emotes");
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
QJsonObject emojies = data->contentJson()["images"].toObject();
|
||||
|
||||
//TODO: Remove with stable migration
|
||||
// TODO: Remove with stable migration
|
||||
const auto legacyEmojies = data->contentJson()["emoticons"].toObject();
|
||||
for(const auto &emoji : legacyEmojies.keys()) {
|
||||
if(!emojies.contains(emoji)) {
|
||||
for (const auto &emoji : legacyEmojies.keys()) {
|
||||
if (!emojies.contains(emoji)) {
|
||||
emojies[emoji] = legacyEmojies[emoji];
|
||||
}
|
||||
}
|
||||
@@ -36,22 +36,18 @@ void CustomEmojiModel::fetchEmojies()
|
||||
beginResetModel();
|
||||
d->emojies.clear();
|
||||
|
||||
for (const auto& emoji : emojies.keys()) {
|
||||
const auto& data = emojies[emoji];
|
||||
for (const auto &emoji : emojies.keys()) {
|
||||
const auto &data = emojies[emoji];
|
||||
|
||||
const auto e = emoji.startsWith(":") ? emoji : (QStringLiteral(":") + emoji + QStringLiteral(":"));
|
||||
|
||||
d->emojies << CustomEmoji {
|
||||
e,
|
||||
data.toObject()["url"].toString(),
|
||||
QRegularExpression(QStringLiteral(R"((^|[^\\]))") + e)
|
||||
};
|
||||
d->emojies << CustomEmoji{e, data.toObject()["url"].toString(), QRegularExpression(QStringLiteral(R"((^|[^\\]))") + e)};
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void CustomEmojiModel::addEmoji(const QString& name, const QUrl& location)
|
||||
void CustomEmojiModel::addEmoji(const QString &name, const QUrl &location)
|
||||
{
|
||||
using namespace Quotient;
|
||||
|
||||
@@ -59,7 +55,7 @@ void CustomEmojiModel::addEmoji(const QString& name, const QUrl& location)
|
||||
|
||||
if (running(job)) {
|
||||
connect(job, &BaseJob::success, this, [this, name, job] {
|
||||
const auto& data = d->conn->accountData("im.ponies.user_emotes");
|
||||
const auto &data = d->conn->accountData("im.ponies.user_emotes");
|
||||
auto json = data != nullptr ? data->contentJson() : QJsonObject();
|
||||
auto emojiData = json["images"].toObject();
|
||||
emojiData[QStringLiteral("%1").arg(name)] = QJsonObject({
|
||||
@@ -75,30 +71,30 @@ void CustomEmojiModel::addEmoji(const QString& name, const QUrl& location)
|
||||
}
|
||||
}
|
||||
|
||||
void CustomEmojiModel::removeEmoji(const QString& name)
|
||||
void CustomEmojiModel::removeEmoji(const QString &name)
|
||||
{
|
||||
using namespace Quotient;
|
||||
|
||||
const auto& data = d->conn->accountData("im.ponies.user_emotes");
|
||||
const auto &data = d->conn->accountData("im.ponies.user_emotes");
|
||||
Q_ASSERT(data != nullptr); // something's screwed if we get here with a nullptr
|
||||
auto json = data->contentJson();
|
||||
const QString _name = name.mid(1).chopped(1);
|
||||
auto emojiData = json["images"].toObject();
|
||||
|
||||
if(emojiData.contains(name)) {
|
||||
if (emojiData.contains(name)) {
|
||||
emojiData.remove(name);
|
||||
json["images"] = emojiData;
|
||||
}
|
||||
if(emojiData.contains(_name)) {
|
||||
if (emojiData.contains(_name)) {
|
||||
emojiData.remove(_name);
|
||||
json["images"] = emojiData;
|
||||
}
|
||||
emojiData = json["emoticons"].toObject();
|
||||
if(emojiData.contains(name)) {
|
||||
if (emojiData.contains(name)) {
|
||||
emojiData.remove(name);
|
||||
json["emoticons"] = emojiData;
|
||||
}
|
||||
if(emojiData.contains(_name)) {
|
||||
if (emojiData.contains(_name)) {
|
||||
emojiData.remove(_name);
|
||||
json["emoticons"] = emojiData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user