mirror of
https://github.com/transmission/transmission
synced 2025-02-21 13:46:52 +00:00
fix: apply alt speed settings on load (#6937)
* fix: apply alt speed settings on load * refactor: allow forcing `tr_session_alt_speeds::set_active()`
This commit is contained in:
parent
5e08164742
commit
415c0a8aa3
2 changed files with 11 additions and 5 deletions
|
@ -22,6 +22,7 @@ void tr_session_alt_speeds::load(Settings&& settings)
|
|||
{
|
||||
settings_ = std::move(settings);
|
||||
update_scheduler();
|
||||
set_active(settings_.is_active, ChangeReason::LoadSettings, true);
|
||||
}
|
||||
|
||||
void tr_session_alt_speeds::update_minutes()
|
||||
|
@ -66,9 +67,9 @@ void tr_session_alt_speeds::check_scheduler()
|
|||
}
|
||||
}
|
||||
|
||||
void tr_session_alt_speeds::set_active(bool active, ChangeReason reason)
|
||||
void tr_session_alt_speeds::set_active(bool active, ChangeReason reason, bool force)
|
||||
{
|
||||
if (auto& tgt = settings_.is_active; tgt != active)
|
||||
if (auto& tgt = settings_.is_active; force || tgt != active)
|
||||
{
|
||||
tgt = active;
|
||||
mediator_.is_active_changed(tgt, reason);
|
||||
|
|
|
@ -63,10 +63,11 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
enum class ChangeReason
|
||||
enum class ChangeReason : uint8_t
|
||||
{
|
||||
User,
|
||||
Scheduler
|
||||
Scheduler,
|
||||
LoadSettings
|
||||
};
|
||||
|
||||
class Mediator
|
||||
|
@ -162,7 +163,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void set_active(bool active, ChangeReason reason);
|
||||
void set_active(bool active, ChangeReason reason)
|
||||
{
|
||||
set_active(active, reason, false);
|
||||
}
|
||||
|
||||
private:
|
||||
Mediator& mediator_;
|
||||
|
@ -171,6 +175,7 @@ private:
|
|||
|
||||
void update_scheduler();
|
||||
void update_minutes();
|
||||
void set_active(bool active, ChangeReason reason, bool force);
|
||||
|
||||
// whether `time` hits in one of the `minutes_` that is true
|
||||
[[nodiscard]] bool is_active_minute(time_t time) const noexcept;
|
||||
|
|
Loading…
Reference in a new issue