mirror of
https://github.com/transmission/transmission.git
synced 2025-12-12 20:35:49 +01:00
refactor: intern recently-active (#7909)
* refactor: intern recently-active * fixup! refactor: intern recently-active fix a couple of literals missed in rpcimpl.cc
This commit is contained in:
@@ -457,6 +457,8 @@ auto constexpr MyStatic = std::array<std::string_view, TR_N_KEYS>{
|
||||
"ratio_mode"sv,
|
||||
"read-clipboard"sv,
|
||||
"read_clipboard"sv,
|
||||
"recently-active"sv,
|
||||
"recently_active"sv,
|
||||
"recheckProgress"sv,
|
||||
"recheck_progress"sv,
|
||||
"remote-session-enabled"sv,
|
||||
|
||||
@@ -455,6 +455,8 @@ enum // NOLINT(performance-enum-size)
|
||||
TR_KEY_ratio_mode,
|
||||
TR_KEY_read_clipboard_kebab,
|
||||
TR_KEY_read_clipboard,
|
||||
TR_KEY_recently_active_kebab,
|
||||
TR_KEY_recently_active,
|
||||
TR_KEY_recheck_progress_camel,
|
||||
TR_KEY_recheck_progress,
|
||||
TR_KEY_remote_session_enabled_kebab,
|
||||
|
||||
@@ -256,7 +256,8 @@ using DoneCb = std::function<void(struct tr_rpc_idle_data* data, JsonRpc::Error:
|
||||
|
||||
if (auto const val = var.value_if<std::string_view>())
|
||||
{
|
||||
if (*val == "recently_active"sv || *val == "recently-active")
|
||||
if (*val == tr_quark_get_string_view(TR_KEY_recently_active) ||
|
||||
*val == tr_quark_get_string_view(TR_KEY_recently_active_kebab))
|
||||
{
|
||||
auto const cutoff = tr_time() - RecentlyActiveSeconds;
|
||||
auto const recent = torrents.get_matching([cutoff](auto* walk) { return walk->has_changed_since(cutoff); });
|
||||
@@ -1144,7 +1145,8 @@ namespace make_torrent_field_helpers
|
||||
TrFormat::Object;
|
||||
|
||||
if (auto val = args_in.value_if<std::string_view>(TR_KEY_ids).value_or(""sv);
|
||||
val == "recently_active"sv || val == "recently-active"sv)
|
||||
val == tr_quark_get_string_view(TR_KEY_recently_active) ||
|
||||
val == tr_quark_get_string_view(TR_KEY_recently_active_kebab))
|
||||
{
|
||||
auto const cutoff = tr_time() - RecentlyActiveSeconds;
|
||||
auto const ids = session->torrents().removedSince(cutoff);
|
||||
|
||||
@@ -388,11 +388,9 @@ void Session::start()
|
||||
|
||||
void Session::addOptionalIds(tr_variant* args_dict, torrent_ids_t const& torrent_ids) const
|
||||
{
|
||||
auto constexpr RecentlyActiveKey = std::string_view{ "recently-active" };
|
||||
|
||||
if (&torrent_ids == &RecentlyActiveIDs)
|
||||
{
|
||||
dictAdd(args_dict, TR_KEY_ids, RecentlyActiveKey);
|
||||
dictAdd(args_dict, TR_KEY_ids, tr_quark_get_string_view(TR_KEY_recently_active_kebab));
|
||||
}
|
||||
else if (!std::empty(torrent_ids))
|
||||
{
|
||||
|
||||
@@ -607,7 +607,7 @@ void add_id_arg(tr_variant::Map& args, std::string_view id_str, std::string_view
|
||||
|
||||
if (IdActive == id_str)
|
||||
{
|
||||
args.insert_or_assign(TR_KEY_ids, "recently-active"sv);
|
||||
args.insert_or_assign(TR_KEY_ids, tr_variant::unmanaged_string(TR_KEY_recently_active_kebab));
|
||||
}
|
||||
else if (IdAll != id_str)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user