fixed crash when moderation buttons are enabled

This commit is contained in:
fourtf
2018-08-12 00:01:37 +02:00
parent b3fd278c3c
commit 1ec1ecd52b
15 changed files with 89 additions and 68 deletions
+5 -4
View File
@@ -5,6 +5,7 @@
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
#include "debug/Log.hpp"
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
namespace chatterino {
@@ -109,12 +110,12 @@ FfzEmotes::FfzEmotes()
{
}
std::shared_ptr<const EmoteMap> FfzEmotes::global() const
std::shared_ptr<const EmoteMap> FfzEmotes::emotes() const
{
return this->global_.get();
}
boost::optional<EmotePtr> FfzEmotes::global(const EmoteName &name) const
boost::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
{
auto emotes = this->global_.get();
auto it = emotes->find(name);
@@ -122,7 +123,7 @@ boost::optional<EmotePtr> FfzEmotes::global(const EmoteName &name) const
return boost::none;
}
void FfzEmotes::loadGlobal()
void FfzEmotes::loadEmotes()
{
QString url("https://api.frankerfacez.com/v1/set/global");
@@ -131,7 +132,7 @@ void FfzEmotes::loadGlobal()
request.setTimeout(30000);
request.onSuccess([this](auto result) -> Outcome {
auto emotes = this->global();
auto emotes = this->emotes();
auto pair = parseGlobalEmotes(result.parseJson(), *emotes);
if (pair.first)
this->global_.set(
+9 -6
View File
@@ -1,24 +1,27 @@
#pragma once
#include <memory>
#include "boost/optional.hpp"
#include "common/Aliases.hpp"
#include "common/Atomic.hpp"
#include "messages/Emote.hpp"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class EmoteMap;
class FfzEmotes final
{
static constexpr const char *globalEmoteApiUrl =
"https://api.frankerfacez.com/v1/set/global";
static constexpr const char *channelEmoteApiUrl =
"https://api.betterttv.net/2/channels/";
public:
FfzEmotes();
std::shared_ptr<const EmoteMap> global() const;
boost::optional<EmotePtr> global(const EmoteName &name) const;
void loadGlobal();
std::shared_ptr<const EmoteMap> emotes() const;
boost::optional<EmotePtr> emote(const EmoteName &name) const;
void loadEmotes();
static void loadChannel(const QString &channelName,
std::function<void(EmoteMap &&)> callback);