Skip to content

Commit 6b1a7c4

Browse files
committed
Fix secondary_action not being optional
Fixes #1
1 parent d38eb6c commit 6b1a7c4

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

  • gravel-provider-custom/src

gravel-provider-custom/src/lib.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,20 @@ fn into_hit(config: HitConfig) -> SimpleHit {
110110
let subtitle = config.subtitle.unwrap_or_default();
111111
let wait = config.wait.unwrap_or(true);
112112

113-
SimpleHit::new(config.title, subtitle, move |h, context| {
113+
let mut hit = SimpleHit::new(config.title, subtitle, move |h, context| {
114114
run_action(&config.action, wait, h);
115115
run_post_action(context, config.post_action);
116116
})
117-
.with_secondary(move |hit, context| {
118-
run_action(&config.secondary_action, wait, hit);
119-
run_post_action(context, config.post_action);
120-
})
121-
.with_score(config.override_score)
117+
.with_score(config.override_score);
118+
119+
if let Some(secondary_action) = config.secondary_action {
120+
hit = hit.with_secondary(move |hit, context| {
121+
run_action(&secondary_action, wait, hit);
122+
run_post_action(context, config.post_action);
123+
});
124+
}
125+
126+
hit
122127
}
123128

124129
fn run_action(action: &Action, wait: bool, hit: &SimpleHit) {
@@ -181,7 +186,7 @@ struct HitConfig {
181186
pub override_score: Option<u32>,
182187
pub wait: Option<bool>,
183188
pub action: Action,
184-
pub secondary_action: Action,
189+
pub secondary_action: Option<Action>,
185190

186191
#[serde(default)]
187192
pub post_action: PostAction,

0 commit comments

Comments
 (0)