@@ -122,10 +122,10 @@ impl<T> FilterList<T> {
122122 }
123123
124124 pub fn toggle ( & mut self ) {
125- if let Some ( index) = self . state . selected ( ) {
126- if let Some ( content_rating) = self . items . get_mut ( index) {
127- content_rating . toggle ( ) ;
128- }
125+ if let Some ( index) = self . state . selected ( )
126+ && let Some ( content_rating) = self . items . get_mut ( index)
127+ {
128+ content_rating . toggle ( ) ;
129129 }
130130 }
131131
@@ -272,10 +272,10 @@ impl FilterList<SortByState> {
272272 item. is_selected = false ;
273273 }
274274
275- if let Some ( index) = self . state . selected ( ) {
276- if let Some ( sort_by) = self . items . get_mut ( index) {
277- sort_by . toggle ( ) ;
278- }
275+ if let Some ( index) = self . state . selected ( )
276+ && let Some ( sort_by) = self . items . get_mut ( index)
277+ {
278+ sort_by . toggle ( ) ;
279279 }
280280 }
281281}
@@ -431,12 +431,11 @@ impl<T: SendEventOnSuccess> FilterListDynamic<T> {
431431 }
432432
433433 fn toggle ( & mut self ) {
434- if let Some ( items) = self . items . as_mut ( ) {
435- if let Some ( index) = self . state . selected ( ) {
436- if let Some ( user_selected) = items. get_mut ( index) {
437- user_selected. is_selected = !user_selected. is_selected ;
438- }
439- }
434+ if let Some ( items) = self . items . as_mut ( )
435+ && let Some ( index) = self . state . selected ( )
436+ && let Some ( user_selected) = items. get_mut ( index)
437+ {
438+ user_selected. is_selected = !user_selected. is_selected ;
440439 }
441440 }
442441
@@ -600,12 +599,11 @@ impl TagsState {
600599 if let Some ( tag) = self . get_selected_tag ( ) {
601600 tag. toggle_include ( ) ;
602601 }
603- } else if self . tags . is_some ( ) {
604- if let Some ( index) = self . state . selected ( ) {
605- if let Some ( tag) = self . get_filtered_tags ( ) . get_mut ( index) {
606- tag. toggle_include ( ) ;
607- }
608- }
602+ } else if self . tags . is_some ( )
603+ && let Some ( index) = self . state . selected ( )
604+ && let Some ( tag) = self . get_filtered_tags ( ) . get_mut ( index)
605+ {
606+ tag. toggle_include ( ) ;
609607 }
610608 }
611609
@@ -614,12 +612,11 @@ impl TagsState {
614612 if let Some ( tag) = self . get_selected_tag ( ) {
615613 tag. toggle_exclude ( ) ;
616614 }
617- } else if self . tags . is_some ( ) {
618- if let Some ( index) = self . state . selected ( ) {
619- if let Some ( tag) = self . get_filtered_tags ( ) . get_mut ( index) {
620- tag. toggle_exclude ( ) ;
621- }
622- }
615+ } else if self . tags . is_some ( )
616+ && let Some ( index) = self . state . selected ( )
617+ && let Some ( tag) = self . get_filtered_tags ( ) . get_mut ( index)
618+ {
619+ tag. toggle_exclude ( ) ;
623620 }
624621 }
625622}
@@ -748,10 +745,10 @@ impl MangadexFilterProvider {
748745 let client = self . api_client . clone ( ) ;
749746 tokio:: spawn ( async move {
750747 let response = client. get_tags ( ) . await ;
751- if let Ok ( res) = response {
752- if let Ok ( tags) = res. json ( ) . await {
753- tx . send ( FilterEvents :: LoadTags ( tags ) ) . ok ( ) ;
754- }
748+ if let Ok ( res) = response
749+ && let Ok ( tags) = res. json ( ) . await
750+ {
751+ tx . send ( FilterEvents :: LoadTags ( tags ) ) . ok ( ) ;
755752 }
756753 } ) ;
757754 }
0 commit comments