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 {
|
||||
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;
|
||||
const QString CLIPS_LINK("https://clips.twitch.tv/%1");
|
||||
const QString CLIPS_FAILURE_CLIPS_DISABLED_TEXT(
|
||||
|
@ -159,7 +159,6 @@ TwitchChannel::TwitchChannel(const QString &name,
|
|||
, bttvEmotes_(std::make_shared<EmoteMap>())
|
||||
, ffzEmotes_(std::make_shared<EmoteMap>())
|
||||
, mod_(false)
|
||||
, titleRefreshedTime_(QTime::currentTime().addSecs(-TITLE_REFRESH_PERIOD))
|
||||
{
|
||||
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
||||
|
||||
|
@ -587,20 +586,20 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
|||
|
||||
void TwitchChannel::refreshTitle()
|
||||
{
|
||||
auto roomID = this->roomId();
|
||||
if (roomID.isEmpty())
|
||||
// timer has never started, proceed and start it
|
||||
if (!this->titleRefreshedTimer_.isValid())
|
||||
{
|
||||
this->titleRefreshedTimer_.start();
|
||||
}
|
||||
else if (this->roomId().isEmpty() ||
|
||||
this->titleRefreshedTimer_.elapsed() < TITLE_REFRESH_PERIOD)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->titleRefreshedTime_.elapsed() < TITLE_REFRESH_PERIOD * 1000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->titleRefreshedTime_ = QTime::currentTime();
|
||||
this->titleRefreshedTimer_.restart();
|
||||
|
||||
getHelix()->getChannel(
|
||||
roomID,
|
||||
this->roomId(),
|
||||
[this, weak = weakOf<Channel>(this)](HelixChannel channel) {
|
||||
ChannelPtr shared = weak.lock();
|
||||
|
||||
|
@ -956,7 +955,12 @@ void TwitchChannel::createClip()
|
|||
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)
|
||||
{
|
||||
return;
|
||||
|
@ -1037,8 +1041,7 @@ void TwitchChannel::createClip()
|
|||
},
|
||||
// finallyCallback - this will always execute, so clip creation won't ever be stuck
|
||||
[this] {
|
||||
this->timeNextClipCreationAllowed_ =
|
||||
QTime().currentTime().addMSecs(CLIP_CREATION_COOLDOWN);
|
||||
this->clipCreationTimer_.restart();
|
||||
this->isClipCreationInProgress = false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <IrcConnection>
|
||||
#include <QColor>
|
||||
#include <QElapsedTimer>
|
||||
#include <QRegularExpression>
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
|
@ -188,8 +189,8 @@ private:
|
|||
QObject lifetimeGuard_;
|
||||
QTimer liveStatusTimer_;
|
||||
QTimer chattersListTimer_;
|
||||
QTime titleRefreshedTime_;
|
||||
QTime timeNextClipCreationAllowed_{QTime().currentTime()};
|
||||
QElapsedTimer titleRefreshedTimer_;
|
||||
QElapsedTimer clipCreationTimer_;
|
||||
bool isClipCreationInProgress{false};
|
||||
|
||||
friend class TwitchIrcServer;
|
||||
|
|
Loading…
Reference in a new issue