refactor: Refactored several usages of sort_by_key and match guards to utilize newer Rust version APIs
This commit is contained in:
42 files changed
+202
-255
No files matched your search
@@ -102,7 +102,7 @@ impl Network<'_, '_> {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
blocklist_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
blocklist_vec.sort_by_key(|a| a.id);
|
||||
app.data.sonarr_data.blocklist.set_items(blocklist_vec);
|
||||
app.data.sonarr_data.blocklist.apply_sorting_toggle(false);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Network<'_, '_> {
|
||||
Route::Sonarr(ActiveSonarrBlock::HistorySortPrompt, _)
|
||||
) {
|
||||
let mut history_vec = history_response.records;
|
||||
history_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
history_vec.sort_by_key(|a| a.id);
|
||||
app.data.sonarr_data.history.set_items(history_vec);
|
||||
app.data.sonarr_data.history.apply_sorting_toggle(false);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ impl Network<'_, '_> {
|
||||
|
||||
self
|
||||
.handle_request::<(), Vec<Episode>>(request_props, |mut episode_vec, mut app| {
|
||||
episode_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
episode_vec.sort_by_key(|a| a.id);
|
||||
if !matches!(
|
||||
app.get_current_route(),
|
||||
Route::Sonarr(ActiveSonarrBlock::EpisodesSortPrompt, _)
|
||||
@@ -151,7 +151,7 @@ impl Network<'_, '_> {
|
||||
.get_or_insert_default();
|
||||
|
||||
let mut history_vec = history_response.records;
|
||||
history_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
history_vec.sort_by_key(|a| a.id);
|
||||
episode_details_modal.episode_history.set_items(history_vec);
|
||||
episode_details_modal
|
||||
.episode_history
|
||||
|
||||
@@ -158,7 +158,7 @@ impl Network<'_, '_> {
|
||||
|
||||
if !is_sorting {
|
||||
let mut history_vec = history_items;
|
||||
history_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
history_vec.sort_by_key(|a| a.id);
|
||||
season_details_modal.season_history.set_items(history_vec);
|
||||
season_details_modal
|
||||
.season_history
|
||||
|
||||
@@ -315,7 +315,7 @@ impl Network<'_, '_> {
|
||||
let series_history = app.data.sonarr_data.series_history.get_or_insert_default();
|
||||
|
||||
if !is_sorting {
|
||||
history_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
history_vec.sort_by_key(|a| a.id);
|
||||
series_history.set_items(history_vec);
|
||||
series_history.apply_sorting_toggle(false);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ impl Network<'_, '_> {
|
||||
app.get_current_route(),
|
||||
Route::Sonarr(ActiveSonarrBlock::SeriesSortPrompt, _)
|
||||
) {
|
||||
series_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
series_vec.sort_by_key(|a| a.id);
|
||||
app.data.sonarr_data.series.set_items(series_vec);
|
||||
app.data.sonarr_data.series.apply_sorting_toggle(false);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ impl Network<'_, '_> {
|
||||
let log_lines = logs
|
||||
.into_iter()
|
||||
.map(|log| {
|
||||
if log.exception.is_some() {
|
||||
if let Some(exception) = log.exception {
|
||||
HorizontallyScrollableText::from(format!(
|
||||
"{}|{}|{}|{}|{}",
|
||||
log.time,
|
||||
@@ -63,10 +63,7 @@ impl Network<'_, '_> {
|
||||
.exception_type
|
||||
.as_ref()
|
||||
.expect("exception_type must exist when exception is present"),
|
||||
log
|
||||
.exception
|
||||
.as_ref()
|
||||
.expect("exception must exist in this branch")
|
||||
exception
|
||||
))
|
||||
} else {
|
||||
HorizontallyScrollableText::from(format!(
|
||||
|
||||
Reference in new issue
Block a user