mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fix moderation button time units when not using seconds (#2864)
This commit is contained in:
parent
9640837957
commit
d21858b97f
|
@ -15,6 +15,7 @@
|
|||
- Minor: Now shows deletions of messages like timeouts (#1155, #2841, #2867, #2874)
|
||||
- Minor: Added a link to accounts page in settings to "You need to be logged in to send messages" message. (#2862)
|
||||
- Minor: Switch to Twitch v2 emote API for animated emote support. (#2863)
|
||||
- Bugfix: Moderation buttons now show the correct time unit when using units other than seconds. (#1719, #2864)
|
||||
- Bugfix: Fixed FFZ emote links for global emotes (#2807, #2808)
|
||||
- Bugfix: Fixed pasting text with URLs included (#1688, #2855)
|
||||
- Bugfix: Fix reconnecting when IRC write connection is lost (#1831, #2356, #2850)
|
||||
|
|
|
@ -29,7 +29,7 @@ ModerationAction::ModerationAction(const QString &action)
|
|||
: action_(action)
|
||||
{
|
||||
static QRegularExpression replaceRegex("[!/.]");
|
||||
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)");
|
||||
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)([mhdw]?)");
|
||||
|
||||
auto timeoutMatch = timeoutRegex.match(action);
|
||||
|
||||
|
@ -39,27 +39,55 @@ ModerationAction::ModerationAction(const QString &action)
|
|||
// QString line1;
|
||||
// QString line2;
|
||||
|
||||
int amount = timeoutMatch.captured(1).toInt();
|
||||
constexpr int minute = 60;
|
||||
constexpr int hour = 60 * minute;
|
||||
constexpr int day = 24 * hour;
|
||||
constexpr int week = 7 * day;
|
||||
|
||||
if (amount < 60)
|
||||
int amount = timeoutMatch.captured(1).toInt();
|
||||
QString unit = timeoutMatch.captured(2);
|
||||
|
||||
if (unit == "m")
|
||||
{
|
||||
amount *= minute;
|
||||
}
|
||||
else if (unit == "h")
|
||||
{
|
||||
amount *= hour;
|
||||
}
|
||||
else if (unit == "d")
|
||||
{
|
||||
amount *= day;
|
||||
}
|
||||
else if (unit == "w")
|
||||
{
|
||||
amount *= week;
|
||||
}
|
||||
|
||||
if (amount < minute)
|
||||
{
|
||||
this->line1_ = QString::number(amount);
|
||||
this->line2_ = "s";
|
||||
}
|
||||
else if (amount < 60 * 60)
|
||||
else if (amount < hour)
|
||||
{
|
||||
this->line1_ = QString::number(amount / 60);
|
||||
this->line1_ = QString::number(amount / minute);
|
||||
this->line2_ = "m";
|
||||
}
|
||||
else if (amount < 60 * 60 * 24)
|
||||
else if (amount < day)
|
||||
{
|
||||
this->line1_ = QString::number(amount / 60 / 60);
|
||||
this->line1_ = QString::number(amount / hour);
|
||||
this->line2_ = "h";
|
||||
}
|
||||
else if (amount < week)
|
||||
{
|
||||
this->line1_ = QString::number(amount / day);
|
||||
this->line2_ = "d";
|
||||
}
|
||||
else
|
||||
{
|
||||
this->line1_ = QString::number(amount / 60 / 60 / 24);
|
||||
this->line2_ = "d";
|
||||
this->line1_ = QString::number(amount / week);
|
||||
this->line2_ = "w";
|
||||
}
|
||||
|
||||
// line1 = this->line1_;
|
||||
|
|
Loading…
Reference in a new issue