refactor: Refactored several usages of sort_by_key and match guards to utilize newer Rust version APIs
This commit is contained in:
@@ -82,7 +82,7 @@ impl Network<'_, '_> {
|
||||
Route::Lidarr(ActiveLidarrBlock::BlocklistSortPrompt, _)
|
||||
) {
|
||||
let mut blocklist_vec: Vec<BlocklistItem> = blocklist_resp.records;
|
||||
blocklist_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
blocklist_vec.sort_by_key(|a| a.id);
|
||||
app.data.lidarr_data.blocklist.set_items(blocklist_vec);
|
||||
app.data.lidarr_data.blocklist.apply_sorting_toggle(false);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Network<'_, '_> {
|
||||
Route::Lidarr(ActiveLidarrBlock::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.lidarr_data.history.set_items(history_vec);
|
||||
app.data.lidarr_data.history.apply_sorting_toggle(false);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ impl Network<'_, '_> {
|
||||
|
||||
self
|
||||
.handle_request::<(), Vec<Album>>(request_props, |mut albums_vec, mut app| {
|
||||
albums_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
albums_vec.sort_by_key(|a| a.id);
|
||||
app.data.lidarr_data.albums.set_items(albums_vec);
|
||||
})
|
||||
.await
|
||||
@@ -89,7 +89,7 @@ impl Network<'_, '_> {
|
||||
.get_or_insert_default();
|
||||
|
||||
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);
|
||||
album_details_modal.album_history.set_items(history_vec);
|
||||
album_details_modal
|
||||
.album_history
|
||||
|
||||
@@ -64,7 +64,7 @@ impl Network<'_, '_> {
|
||||
app.get_current_route(),
|
||||
Route::Lidarr(ActiveLidarrBlock::ArtistsSortPrompt, _)
|
||||
) {
|
||||
artists_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
artists_vec.sort_by_key(|a| a.id);
|
||||
app.data.lidarr_data.artists.set_items(artists_vec);
|
||||
app.data.lidarr_data.artists.apply_sorting_toggle(false);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ impl Network<'_, '_> {
|
||||
let artist_history = &mut app.data.lidarr_data.artist_history;
|
||||
|
||||
if !is_sorting {
|
||||
history_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
history_vec.sort_by_key(|a| a.id);
|
||||
artist_history.set_items(history_vec);
|
||||
artist_history.apply_sorting_toggle(false);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ impl Network<'_, '_> {
|
||||
|
||||
self
|
||||
.handle_request::<(), Vec<Track>>(request_props, |mut track_vec, mut app| {
|
||||
track_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
track_vec.sort_by_key(|a| a.id);
|
||||
let album_details_modal = app
|
||||
.data
|
||||
.lidarr_data
|
||||
@@ -238,7 +238,7 @@ impl Network<'_, '_> {
|
||||
.into_iter()
|
||||
.filter(|it| it.track_id == track_id)
|
||||
.collect();
|
||||
history_vec.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
history_vec.sort_by_key(|a| a.id);
|
||||
track_details_modal.track_history.set_items(history_vec);
|
||||
track_details_modal
|
||||
.track_history
|
||||
|
||||
@@ -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