mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixed deprecated method QTime::elapsed (#2504)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
cd1f4d0c78
commit
ce947a89d7
2 changed files with 21 additions and 17 deletions
|
@ -36,7 +36,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace {
|
namespace {
|
||||||
constexpr char MAGIC_MESSAGE_SUFFIX[] = u8" \U000E0000";
|
constexpr char MAGIC_MESSAGE_SUFFIX[] = u8" \U000E0000";
|
||||||
constexpr int TITLE_REFRESH_PERIOD = 10;
|
constexpr int TITLE_REFRESH_PERIOD = 10000;
|
||||||
constexpr int CLIP_CREATION_COOLDOWN = 5000;
|
constexpr int CLIP_CREATION_COOLDOWN = 5000;
|
||||||
const QString CLIPS_LINK("https://clips.twitch.tv/%1");
|
const QString CLIPS_LINK("https://clips.twitch.tv/%1");
|
||||||
const QString CLIPS_FAILURE_CLIPS_DISABLED_TEXT(
|
const QString CLIPS_FAILURE_CLIPS_DISABLED_TEXT(
|
||||||
|
@ -159,7 +159,6 @@ TwitchChannel::TwitchChannel(const QString &name,
|
||||||
, bttvEmotes_(std::make_shared<EmoteMap>())
|
, bttvEmotes_(std::make_shared<EmoteMap>())
|
||||||
, ffzEmotes_(std::make_shared<EmoteMap>())
|
, ffzEmotes_(std::make_shared<EmoteMap>())
|
||||||
, mod_(false)
|
, mod_(false)
|
||||||
, titleRefreshedTime_(QTime::currentTime().addSecs(-TITLE_REFRESH_PERIOD))
|
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
||||||
|
|
||||||
|
@ -587,20 +586,20 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
|
|
||||||
void TwitchChannel::refreshTitle()
|
void TwitchChannel::refreshTitle()
|
||||||
{
|
{
|
||||||
auto roomID = this->roomId();
|
// timer has never started, proceed and start it
|
||||||
if (roomID.isEmpty())
|
if (!this->titleRefreshedTimer_.isValid())
|
||||||
|
{
|
||||||
|
this->titleRefreshedTimer_.start();
|
||||||
|
}
|
||||||
|
else if (this->roomId().isEmpty() ||
|
||||||
|
this->titleRefreshedTimer_.elapsed() < TITLE_REFRESH_PERIOD)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this->titleRefreshedTimer_.restart();
|
||||||
if (this->titleRefreshedTime_.elapsed() < TITLE_REFRESH_PERIOD * 1000)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->titleRefreshedTime_ = QTime::currentTime();
|
|
||||||
|
|
||||||
getHelix()->getChannel(
|
getHelix()->getChannel(
|
||||||
roomID,
|
this->roomId(),
|
||||||
[this, weak = weakOf<Channel>(this)](HelixChannel channel) {
|
[this, weak = weakOf<Channel>(this)](HelixChannel channel) {
|
||||||
ChannelPtr shared = weak.lock();
|
ChannelPtr shared = weak.lock();
|
||||||
|
|
||||||
|
@ -956,7 +955,12 @@ void TwitchChannel::createClip()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QTime().currentTime() < this->timeNextClipCreationAllowed_ ||
|
// timer has never started, proceed and start it
|
||||||
|
if (!this->clipCreationTimer_.isValid())
|
||||||
|
{
|
||||||
|
this->clipCreationTimer_.start();
|
||||||
|
}
|
||||||
|
else if (this->clipCreationTimer_.elapsed() < CLIP_CREATION_COOLDOWN ||
|
||||||
this->isClipCreationInProgress)
|
this->isClipCreationInProgress)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1037,8 +1041,7 @@ void TwitchChannel::createClip()
|
||||||
},
|
},
|
||||||
// finallyCallback - this will always execute, so clip creation won't ever be stuck
|
// finallyCallback - this will always execute, so clip creation won't ever be stuck
|
||||||
[this] {
|
[this] {
|
||||||
this->timeNextClipCreationAllowed_ =
|
this->clipCreationTimer_.restart();
|
||||||
QTime().currentTime().addMSecs(CLIP_CREATION_COOLDOWN);
|
|
||||||
this->isClipCreationInProgress = false;
|
this->isClipCreationInProgress = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <IrcConnection>
|
#include <IrcConnection>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QElapsedTimer>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <pajlada/signals/signalholder.hpp>
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
|
@ -188,8 +189,8 @@ private:
|
||||||
QObject lifetimeGuard_;
|
QObject lifetimeGuard_;
|
||||||
QTimer liveStatusTimer_;
|
QTimer liveStatusTimer_;
|
||||||
QTimer chattersListTimer_;
|
QTimer chattersListTimer_;
|
||||||
QTime titleRefreshedTime_;
|
QElapsedTimer titleRefreshedTimer_;
|
||||||
QTime timeNextClipCreationAllowed_{QTime().currentTime()};
|
QElapsedTimer clipCreationTimer_;
|
||||||
bool isClipCreationInProgress{false};
|
bool isClipCreationInProgress{false};
|
||||||
|
|
||||||
friend class TwitchIrcServer;
|
friend class TwitchIrcServer;
|
||||||
|
|
Loading…
Reference in a new issue