@@ -360,7 +360,7 @@ pub fn SkillsSection() -> impl IntoView {
360360 <Stack title="skills" >
361361 <ScrollXBar >
362362 <For
363- each=move || ( 0 ..settings. read( ) . layout. skills. len( ) )
363+ each=move || 0 ..settings. read( ) . layout. skills. len( )
364364 key=|index| format!( "skills-section-stack-{}" , index)
365365 let : index
366366 >
@@ -381,17 +381,17 @@ pub fn SkillsSection() -> impl IntoView {
381381 alt=|| "Start year" . to_string( )
382382 placeholder=|| "Enter start year" . to_string( )
383383 action=move |ev| {
384- set_settings. update( |x| x. layout. skills[ index] . since. start = ev. target( ) . value( ) . parse( ) . unwrap_or_default( ) ) ;
384+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . since. start = ev. target( ) . value( ) . parse:: < usize > ( ) . unwrap_or_default ( ) ) . unwrap_or_default( ) ) ;
385385 }
386- prop=move || settings. read ( ) . layout. skills[ index] . since. start. to_string( )
386+ prop=move || settings. with ( |x| x . layout. skills. get ( index) . map ( |x| x . since. start) . unwrap_or_default ( ) ) . to_string( )
387387 />
388388 <InputNumeric
389389 alt=|| "End year" . to_string( )
390390 placeholder=|| "Enter end year" . to_string( )
391391 action=move |ev| {
392- set_settings. update( |x| x. layout. skills[ index] . since. end = ev. target( ) . value( ) . parse( ) . unwrap_or_default( ) ) ;
392+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . since. end = ev. target( ) . value( ) . parse( ) . unwrap_or_default ( ) ) . unwrap_or_default( ) ) ;
393393 }
394- prop=move || settings. read ( ) . layout. skills[ index] . since. end. to_string( )
394+ prop=move || settings. with ( |x| x . layout. skills. get ( index) . map ( |x| x . since. end) . unwrap_or_default ( ) ) . to_string( )
395395 />
396396 </div>
397397 </Show >
@@ -404,17 +404,17 @@ pub fn SkillsSection() -> impl IntoView {
404404 alt=|| "Repository link" . to_string( )
405405 placeholder=|| "Enter repository URL" . to_string( )
406406 action=move |ev| {
407- set_settings. update( |x| x. layout. skills[ index] . repo_link. link = ev. target( ) . value( ) ) ;
407+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . repo_link. link = ev. target( ) . value( ) ) . unwrap_or_default ( ) ) ;
408408 }
409- prop=move || settings. read ( ) . layout. skills[ index] . repo_link. link. clone( )
409+ prop=move || settings. with ( |x| x . layout. skills. get ( index) . map ( |x| x . repo_link. link. clone( ) ) . unwrap_or_default ( ) )
410410 />
411411 <IconSelector
412412 action=move |ev| {
413413 if let Ok ( value) = event_target_value( & ev) . parse( ) {
414- set_settings. update( |x| x. layout. skills[ index] . repo_link. icon = value) ;
414+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . repo_link. icon = value) . unwrap_or_default ( ) ) ;
415415 }
416416 }
417- prop=move || settings. read ( ) . layout. skills[ index] . repo_link. icon. to_string( )
417+ prop=move || settings. with ( |x| x . layout. skills. get ( index) . map ( |x| x . repo_link. icon. to_string( ) ) . unwrap_or_default ( ) )
418418 />
419419 </ScrollableBox >
420420 </Show >
@@ -424,7 +424,7 @@ pub fn SkillsSection() -> impl IntoView {
424424 >
425425 <Stack title="projects" >
426426 <For
427- each=move || ( 0 ..settings. read( ) . layout. skills[ index] . projects. len( ) )
427+ each=move || ( 0 ..settings. read( ) . layout. skills. get ( index) . map ( |x| x . projects. len( ) ) . unwrap_or_default ( ) )
428428 key=|project_index| format!( "skills-section-stack-project-section-stack-{}" , project_index)
429429 let : project_index
430430 >
@@ -433,41 +433,41 @@ pub fn SkillsSection() -> impl IntoView {
433433 alt=|| "Project name" . to_string( )
434434 placeholder=|| "Enter project name" . to_string( )
435435 action=move |ev| {
436- set_settings. update( |x| x. layout. skills[ index] . projects[ project_index] . name = ev. target( ) . value( ) ) ;
436+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . projects[ project_index] . name = ev. target( ) . value( ) ) . unwrap_or_default ( ) ) ;
437437 }
438- prop=move || settings. read( ) . layout. skills[ index] . projects[ project_index] . name. clone( )
439- maxlength=move || limitations. read ( ) . skills ( ) . 1 . projects . unwrap_or_default ( ) . 1
438+ prop=move || settings. read( ) . layout. skills. get ( index) . map ( |x| x . projects[ project_index] . name. clone( ) ) . unwrap_or_default ( )
439+ maxlength=move || limitations. with ( |x| x . skills_projects ( ) . 1 )
440440 />
441441 <InputUrl
442442 alt=|| "Project link" . to_string( )
443443 placeholder=|| "Enter project URL" . to_string( )
444444 action=move |ev| {
445- set_settings. update( |x| x. layout. skills[ index] . projects[ project_index] . link. link = ev. target( ) . value( ) ) ;
445+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . projects[ project_index] . link. link = ev. target( ) . value( ) ) . unwrap_or_default ( ) ) ;
446446 }
447- prop=move || settings. read( ) . layout. skills[ index] . projects[ project_index] . link. link. clone( )
447+ prop=move || settings. read( ) . layout. skills. get ( index) . map ( |x| x . projects[ project_index] . link. link. clone( ) ) . unwrap_or_default ( )
448448 />
449449 <IconSelector
450450 action=move |ev| {
451451 if let Ok ( value) = event_target_value( & ev) . parse( ) {
452- set_settings. update( |x| x. layout. skills[ index] . projects[ project_index] . link. icon = value) ;
452+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . projects[ project_index] . link. icon = value) . unwrap_or_default ( ) ) ;
453453 }
454454 }
455455 prop=move || settings. read( ) . layout. skills[ index] . projects[ project_index] . link. icon. to_string( )
456456 />
457457 <Button
458458 alt=|| "Remove project" . to_string( )
459459 action=move || {
460- set_settings. update( |x| { x. layout. skills[ index] . projects. remove( project_index) ; } ) ;
460+ set_settings. update( |x| { x. layout. skills. get_mut ( index) . map ( |x| x . projects. remove( project_index) ) . unwrap_or_default ( ) ; } ) ;
461461 }
462462 style = ButtonStyle :: Remove
463463 />
464464 </ScrollableBox >
465465 </For >
466- <Show when=move || settings. read( ) . layout. skills[ index] . projects. len( ) < limitations. read( ) . skills_projects( ) . 0 >
466+ <Show when=move || settings. read( ) . layout. skills. get ( index) . map ( |x| x . projects. len( ) ) . unwrap_or_default ( ) < limitations. read( ) . skills_projects( ) . 0 >
467467 <Button
468468 alt=|| "Add new project" . to_string( )
469469 action=move || {
470- set_settings. update( |x| x. layout. skills[ index] . projects. push( Project :: default ( ) ) ) ;
470+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . projects. push( Project :: default ( ) ) ) . unwrap_or_default ( ) ) ;
471471 }
472472 style = ButtonStyle :: Add
473473 />
@@ -479,11 +479,11 @@ pub fn SkillsSection() -> impl IntoView {
479479 <button
480480 title="main"
481481 on: click=move |_| {
482- set_settings. update( |x| x. layout. skills[ index] . main = !x. layout . skills [ index ] . main) ;
482+ set_settings. update( |x| x. layout. skills. get_mut ( index) . map ( |x| x . main = !x. main) . unwrap_or_default ( ) ) ;
483483 }
484484 class="border"
485485 style=move || {
486- if !settings. read( ) . layout. skills[ index] . main {
486+ if !settings. read( ) . layout. skills. get ( index) . map ( |x| x . main) . unwrap_or_default ( ) {
487487 format!(
488488 "background-color: {}; color: {}; border-color: {};" ,
489489 themes. get( ) . colors( ) . background,
0 commit comments