Fix users being assigned duplicate FrankerFaceZ badges (#4156)

This commit is contained in:
pajlada 2022-11-16 11:02:54 +01:00 committed by GitHub
parent 011facc13a
commit 991cf6364d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View file

@ -99,6 +99,7 @@
- Bugfix: Fixed existing emote popups not being raised from behind other windows when refocusing them on macOS (#3713)
- Bugfix: Fixed automod queue pubsub topic persisting after user change. (#3718)
- Bugfix: Fixed viewer list not closing after pressing escape key. (#3734)
- Bugfix: Fixed users being assigned duplicate FrankerFaceZ badges. (#4155)
- Bugfix: Fixed links with no thumbnail having previous link's thumbnail. (#3720)
- Bugfix: Fixed message only showing a maximum of one global FrankerFaceZ badge even if the user has multiple. (#3818)
- Bugfix: Added an icon in the CMake macOS bundle. (#3832)

View file

@ -92,12 +92,12 @@ void FfzBadges::load()
auto userIDString = QString::number(user.toInt());
auto [userBadges, created] = this->userBadges.emplace(
std::make_pair<QString, std::vector<int>>(
std::make_pair<QString, std::set<int>>(
std::move(userIDString), {badgeID}));
if (!created)
{
// User already had a badge assigned
userBadges->second.push_back(badgeID);
userBadges->second.emplace(badgeID);
}
}
}

View file

@ -1,20 +1,20 @@
#pragma once
#include <boost/optional.hpp>
#include <common/Singleton.hpp>
#include "common/Aliases.hpp"
#include "common/UniqueAccess.hpp"
#include "util/QStringHash.hpp"
#include <QColor>
#include <boost/optional.hpp>
#include <common/Singleton.hpp>
#include <map>
#include <memory>
#include <set>
#include <shared_mutex>
#include <unordered_map>
#include <vector>
#include <QColor>
namespace chatterino {
struct Emote;
@ -41,7 +41,7 @@ private:
std::shared_mutex mutex_;
// userBadges points a user ID to the list of badges they have
std::unordered_map<QString, std::vector<int>> userBadges;
std::unordered_map<QString, std::set<int>> userBadges;
// badges points a badge ID to the information about the badge
std::unordered_map<int, Badge> badges;