File tree Expand file tree Collapse file tree 3 files changed +21
-23
lines changed
Expand file tree Collapse file tree 3 files changed +21
-23
lines changed Original file line number Diff line number Diff line change @@ -123,20 +123,19 @@ pub(super) fn main_handler(key_event: KeyEvent, app: &mut App) {
123123}
124124
125125fn handle_counter_switch ( app : & mut App , increment : bool ) {
126- if let Some ( selected) = app. table . state . selected ( ) {
127- if let Some ( element) = app. database . mut_element ( selected) {
128- if element. type_ == OTPType :: Hotp {
129- // safe to unwrap because the element type is HOTP
130- let counter = element. counter . unwrap ( ) ;
131- element. counter = if increment {
132- Some ( counter. checked_add ( 1 ) . unwrap_or ( u64:: MAX ) )
133- } else {
134- Some ( counter. saturating_sub ( 1 ) )
135- } ;
136- app. database . mark_modified ( ) ;
137- app. tick ( true ) ;
138- }
139- }
126+ if let Some ( selected) = app. table . state . selected ( )
127+ && let Some ( element) = app. database . mut_element ( selected)
128+ && element. type_ == OTPType :: Hotp
129+ {
130+ // safe to unwrap because the element type is HOTP
131+ let counter = element. counter . unwrap ( ) ;
132+ element. counter = if increment {
133+ Some ( counter. saturating_add ( 1 ) )
134+ } else {
135+ Some ( counter. saturating_sub ( 1 ) )
136+ } ;
137+ app. database . mark_modified ( ) ;
138+ app. tick ( true ) ;
140139 }
141140}
142141
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ impl Row {
2121 + 1 ) as u16
2222 }
2323
24- pub fn cells ( & self ) -> Vec < Cell > {
24+ pub fn cells ( & self ) -> Vec < Cell < ' _ > > {
2525 self . values
2626 . iter ( )
2727 . map ( |c| {
Original file line number Diff line number Diff line change @@ -38,14 +38,13 @@ fn get_default_db_path() -> PathBuf {
3838 data_dir ( )
3939 . map ( |p| p. join ( XDG_PATH ) )
4040 . inspect ( |xdg| {
41- if !xdg. exists ( ) {
42- if let Some ( home) = & home_path {
43- if home. exists ( ) {
44- fs:: create_dir_all ( xdg. parent ( ) . unwrap ( ) ) . expect ( "Failed to create dir" ) ;
45- fs:: copy ( home, xdg. as_path ( ) )
46- . expect ( "Failed on copy from legacy dir to XDG_DATA_HOME" ) ;
47- }
48- }
41+ if !xdg. exists ( )
42+ && let Some ( home) = & home_path
43+ && home. exists ( )
44+ {
45+ fs:: create_dir_all ( xdg. parent ( ) . unwrap ( ) ) . expect ( "Failed to create dir" ) ;
46+ fs:: copy ( home, xdg. as_path ( ) )
47+ . expect ( "Failed on copy from legacy dir to XDG_DATA_HOME" ) ;
4948 }
5049 } )
5150 . or ( home_path)
You can’t perform that action at this time.
0 commit comments