Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions oma-topics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<'a> TopicManager<'a> {
}

/// Enable select topic
pub fn add(&mut self, topic: &str) -> Result<()> {
pub fn add(&mut self, topic: &str) -> Result<Topic> {
debug!("oma will opt_in: {}", topic);

let index = self
Expand All @@ -220,11 +220,13 @@ impl<'a> TopicManager<'a> {
debug!("Enabled: {enabled_names:?}");

if let Some(index) = index {
let ic = index.clone();
let icc = index.clone();
if !enabled_names.contains(&&index.name) {
self.enabled.push(index.clone());
self.enabled.push(ic);
}

return Ok(());
return Ok(icc);
}

debug!("index: {index:?} does not exist");
Expand Down
11 changes: 4 additions & 7 deletions src/subcommand/topics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,11 @@ async fn topics_inner(
.unwrap()?;
}

let mut enabled_pkgs = vec![];

for i in opt_in {
tm.add(i)?;
let t = tm.add(i)?;
enabled_pkgs.extend(t.packages);
}

let mut downgrade_pkgs = vec![];
Expand All @@ -460,12 +463,6 @@ async fn topics_inner(
downgrade_pkgs.extend(removed_topic.packages);
}

let enabled_pkgs = tm
.enabled_topics()
.iter()
.flat_map(|x| x.packages.clone())
.collect::<Vec<_>>();

Ok(TopicChanged {
enabled_pkgs,
downgrade_pkgs,
Expand Down
Loading