mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Fix tags
This commit is contained in:
parent
1a83a982fc
commit
1c98426536
2 changed files with 18 additions and 17 deletions
|
@ -1235,11 +1235,11 @@ Cache::saveState(const mtx::responses::Sync &res)
|
||||||
updatedInfo.avatar_url = getRoomAvatarUrl(txn, statesdb, membersdb).toStdString();
|
updatedInfo.avatar_url = getRoomAvatarUrl(txn, statesdb, membersdb).toStdString();
|
||||||
updatedInfo.version = getRoomVersion(txn, statesdb).toStdString();
|
updatedInfo.version = getRoomVersion(txn, statesdb).toStdString();
|
||||||
|
|
||||||
|
bool has_new_tags = false;
|
||||||
// Process the account_data associated with this room
|
// Process the account_data associated with this room
|
||||||
if (!room.second.account_data.events.empty()) {
|
if (!room.second.account_data.events.empty()) {
|
||||||
auto accountDataDb = getAccountDataDb(txn, room.first);
|
auto accountDataDb = getAccountDataDb(txn, room.first);
|
||||||
|
|
||||||
bool has_new_tags = false;
|
|
||||||
for (const auto &evt : room.second.account_data.events) {
|
for (const auto &evt : room.second.account_data.events) {
|
||||||
std::visit(
|
std::visit(
|
||||||
[&txn, &accountDataDb](const auto &event) {
|
[&txn, &accountDataDb](const auto &event) {
|
||||||
|
@ -1266,13 +1266,14 @@ Cache::saveState(const mtx::responses::Sync &res)
|
||||||
nhlog::db()->debug("Fully read: {}", fr->content.event_id);
|
nhlog::db()->debug("Fully read: {}", fr->content.event_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!has_new_tags) {
|
if (!has_new_tags) {
|
||||||
// retrieve the old tags, they haven't changed
|
// retrieve the old tags, they haven't changed
|
||||||
lmdb::val data;
|
lmdb::val data;
|
||||||
if (lmdb::dbi_get(txn, roomsDb_, lmdb::val(room.first), data)) {
|
if (lmdb::dbi_get(txn, roomsDb_, lmdb::val(room.first), data)) {
|
||||||
try {
|
try {
|
||||||
RoomInfo tmp = json::parse(
|
RoomInfo tmp =
|
||||||
std::string_view(data.data(), data.size()));
|
json::parse(std::string_view(data.data(), data.size()));
|
||||||
updatedInfo.tags = tmp.tags;
|
updatedInfo.tags = tmp.tags;
|
||||||
} catch (const json::exception &e) {
|
} catch (const json::exception &e) {
|
||||||
nhlog::db()->warn(
|
nhlog::db()->warn(
|
||||||
|
@ -1283,7 +1284,6 @@ Cache::saveState(const mtx::responses::Sync &res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lmdb::dbi_put(
|
lmdb::dbi_put(
|
||||||
txn, roomsDb_, lmdb::val(room.first), lmdb::val(json(updatedInfo).dump()));
|
txn, roomsDb_, lmdb::val(room.first), lmdb::val(json(updatedInfo).dump()));
|
||||||
|
|
|
@ -145,11 +145,12 @@ RoomInfoListItem::init(QWidget *parent)
|
||||||
tagAction->setWhatsThis(tr("Adds or removes the specified tag.",
|
tagAction->setWhatsThis(tr("Adds or removes the specified tag.",
|
||||||
"WhatsThis hint for tag menu actions"));
|
"WhatsThis hint for tag menu actions"));
|
||||||
|
|
||||||
for (const auto &riTag : roomInfo.tags)
|
for (const auto &riTag : roomInfo.tags) {
|
||||||
if (riTag == tag) {
|
if (riTag == tag) {
|
||||||
tagAction->setChecked(true);
|
tagAction->setChecked(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect(tagAction, &QAction::triggered, this, [this, tag](bool checked) {
|
connect(tagAction, &QAction::triggered, this, [this, tag](bool checked) {
|
||||||
if (checked)
|
if (checked)
|
||||||
|
|
Loading…
Reference in a new issue