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) {
123
123
}
124
124
125
125
fn 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 ) ;
140
139
}
141
140
}
142
141
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ impl Row {
21
21
+ 1 ) as u16
22
22
}
23
23
24
- pub fn cells ( & self ) -> Vec < Cell > {
24
+ pub fn cells ( & self ) -> Vec < Cell < ' _ > > {
25
25
self . values
26
26
. iter ( )
27
27
. map ( |c| {
Original file line number Diff line number Diff line change @@ -38,14 +38,13 @@ fn get_default_db_path() -> PathBuf {
38
38
data_dir ( )
39
39
. map ( |p| p. join ( XDG_PATH ) )
40
40
. 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" ) ;
49
48
}
50
49
} )
51
50
. or ( home_path)
You can’t perform that action at this time.
0 commit comments