[yew-devel] [PATCH yew-comp 3/4] wizard: optimize enbaled check for next button

Dominik Csapak d.csapak at proxmox.com
Wed May 7 10:23:44 CEST 2025


On 5/7/25 10:15, Shannon Sterz wrote:
> On Tue May 6, 2025 at 3:26 PM CEST, Dominik Csapak wrote:
>> by first checking for `self.loading` since we don't have to iterate
>> over the wizard pages if that is true.
>>
>> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
>> ---
>>   src/wizard.rs | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/wizard.rs b/src/wizard.rs
>> index e33d3c6..16b1dd8 100644
>> --- a/src/wizard.rs
>> +++ b/src/wizard.rs
>> @@ -635,11 +635,11 @@ impl PwtWizard {
>>               Some(key) => props.pages.get_index_of(key).unwrap_or(0),
>>           };
>>
>> -        let mut next_is_enabled = state.can_progress();
>> -
>> -        if self.loading {
>> -            next_is_enabled = false;
>> -        }
>> +        let next_is_enabled = if self.loading {
>> +            false
>> +        } else {
>> +            state.can_progress()
>> +        };
> 
> couldn't this be more simply:
> 
> let next_is_enabled = !self.loading && state.can_progress();
> 
> i think that reads a bit more easily ("state isn't `loading` and we can
> progress").
> 

true,, i'll send a v2

>>
>>           let next_page = props
>>               .pages
> 





More information about the yew-devel mailing list