Skip to content

Commit

Permalink
Fix some issued spotted by Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Nov 18, 2023
1 parent 19240df commit 17f7aed
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/model/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ pub const RECORD_TYPE_WEBSITE: RecordType = RecordType {
username_field: Some("username"),
password_field: Some("password"),
};
pub const RECORD_TYPES: &'static [&RecordType] = &[

pub const RECORD_TYPES: &[&RecordType] = &[
&RECORD_TYPE_GROUP,
&RECORD_TYPE_GENERIC,
&RECORD_TYPE_CREDITCARD,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/file_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod imp {
let action_bar = gtk::ActionBar::builder().hexpand(true).build();
action_bar.pack_start(&action_popover_button(
&RecordTypePopoverBuilder::default()
.record_types(&RECORD_TYPES)
.record_types(RECORD_TYPES)
.action_name_func(|record_type| format!("file.add::{}", record_type.name))
.build(),
"ps-add",
Expand Down
5 changes: 2 additions & 3 deletions src/ui/group_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ pub async fn select_group(
}),
);

let result = match dlg.run().await {
match dlg.run().await {
Some(gtk::ResponseType::Ok) => get_selected_record(&selection_model),
_ => None,
};
result
}
}
11 changes: 8 additions & 3 deletions src/ui/record_view/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,17 @@ mod imp {
context_menu.popup();
}

fn record_url(&self) -> Option<String> {
let record = self.record.borrow();
let url = record.as_ref()?.record().url()?;
Some(url.to_string())
}

async fn on_open_clicked(&self) {
self.obj().grab_focus();

let record_ref = self.record.borrow();
if let Some(url) = record_ref.as_ref().and_then(|n| n.record().url()) {
show_uri(self.root_window().as_ref(), url).await;
if let Some(url) = self.record_url() {
show_uri(self.root_window().as_ref(), &url).await;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/ui/record_view/item_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ impl PSListItemFactory for RecordListItemFactory {
let Some(record_node) = get_record_node(list_item) else {
return;
};
self.mapping.remove_value(&record_item);
self.mapping.add(list_item.position(), &record_item);
self.mapping.remove_value(record_item);
self.mapping.add(list_item.position(), record_item);
record_item.set_record_node(Some(record_node));
}

fn unbind(&self, list_item: &gtk::ListItem, record_item: &PSRecordViewItem) {
self.mapping.remove_key(list_item.position());
self.mapping.remove_value(&record_item);
self.mapping.remove_value(record_item);
record_item.set_record_node(None);
}

fn teardown(&self, _list_item: &gtk::ListItem, record_item: &PSRecordViewItem) {
record_item.set_record_node(None);
self.mapping.remove_value(&record_item);
self.mapping.remove_value(record_item);
}
}

Expand Down

0 comments on commit 17f7aed

Please sign in to comment.