Only set an utterance ID on the returned variant if we have one.

This commit is contained in:
Nolan Darilek 2020-09-30 15:25:59 -05:00
parent ed7f3920f6
commit ff247a3f19

View File

@ -178,9 +178,11 @@ impl TTS {
let message = message.to_string(); let message = message.to_string();
if let Ok(id) = self.0.speak(message, interrupt) { if let Ok(id) = self.0.speak(message, interrupt) {
let utterance: Instance<Utterance, Unique> = Instance::new(); let utterance: Instance<Utterance, Unique> = Instance::new();
if id.is_some() {
utterance utterance
.map_mut(|u, _| u.0 = id) .map_mut(|u, _| u.0 = id)
.expect("Failed to set utterance ID"); .expect("Failed to set utterance ID");
}
Some(utterance.owned_to_variant()) Some(utterance.owned_to_variant())
} else { } else {
None None