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:
Charles Kerr
2025-12-09 21:15:07 -06:00
committed by GitHub
parent 64231c1076
commit 9f911d4d52
5 changed files with 10 additions and 6 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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);

View File

@@ -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))
{

View File

@@ -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)
{