Skip to content

Commit

Permalink
Merge pull request #200 from GeekGene/chore/remove-signals
Browse files Browse the repository at this point in the history
chore(dna): remove unused signal emitting on post_commit
  • Loading branch information
mattyg authored Aug 31, 2023
2 parents d28bb37 + c697721 commit 8113b81
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 124 deletions.
40 changes: 0 additions & 40 deletions dnas/mewsfeed/zomes/coordinator/agent_pins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,3 @@ pub enum Signal {
link_type: LinkTypes,
},
}
#[hdk_extern(infallible)]
pub fn post_commit(committed_actions: Vec<SignedActionHashed>) {
for action in committed_actions {
if let Err(err) = signal_action(action) {
error!("Error signaling new action: {:?}", err);
}
}
}
fn signal_action(action: SignedActionHashed) -> ExternResult<()> {
match action.hashed.content.clone() {
Action::CreateLink(create_link) => {
if let Ok(Some(link_type)) =
LinkTypes::from_type(create_link.zome_index, create_link.link_type)
{
emit_signal(Signal::LinkCreated { action, link_type })?;
}
Ok(())
}
Action::DeleteLink(delete_link) => {
let record =
get(delete_link.link_add_address, GetOptions::default())?.ok_or(wasm_error!(
WasmErrorInner::Guest("Failed to fetch CreateLink action".to_string())
))?;
match record.action() {
Action::CreateLink(create_link) => {
if let Ok(Some(link_type)) =
LinkTypes::from_type(create_link.zome_index, create_link.link_type)
{
emit_signal(Signal::LinkDeleted { action, link_type })?;
}
Ok(())
}
_ => Err(wasm_error!(WasmErrorInner::Guest(
"Create Link should exist".to_string()
))),
}
}
_ => Ok(()),
}
}
42 changes: 0 additions & 42 deletions dnas/mewsfeed/zomes/coordinator/follows/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,3 @@ pub enum Signal {
link_type: LinkTypes,
},
}

#[hdk_extern(infallible)]
pub fn post_commit(committed_actions: Vec<SignedActionHashed>) {
for action in committed_actions {
if let Err(err) = signal_action(action) {
error!("Error signaling new action: {:?}", err);
}
}
}

fn signal_action(action: SignedActionHashed) -> ExternResult<()> {
match action.hashed.content.clone() {
Action::CreateLink(create_link) => {
if let Ok(Some(link_type)) =
LinkTypes::from_type(create_link.zome_index, create_link.link_type)
{
emit_signal(Signal::LinkCreated { action, link_type })?;
}
Ok(())
}
Action::DeleteLink(delete_link) => {
let record =
get(delete_link.link_add_address, GetOptions::default())?.ok_or(wasm_error!(
WasmErrorInner::Guest("Failed to fetch CreateLink action".to_string())
))?;
match record.action() {
Action::CreateLink(create_link) => {
if let Ok(Some(link_type)) =
LinkTypes::from_type(create_link.zome_index, create_link.link_type)
{
emit_signal(Signal::LinkDeleted { action, link_type })?;
}
Ok(())
}
_ => Err(wasm_error!(WasmErrorInner::Guest(
"Create Link should exist".to_string()
))),
}
}
_ => Ok(()),
}
}
42 changes: 0 additions & 42 deletions dnas/mewsfeed/zomes/coordinator/likes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,3 @@ pub enum Signal {
link_type: LinkTypes,
},
}

#[hdk_extern(infallible)]
pub fn post_commit(committed_actions: Vec<SignedActionHashed>) {
for action in committed_actions {
if let Err(err) = signal_action(action) {
error!("Error signaling new action: {:?}", err);
}
}
}

fn signal_action(action: SignedActionHashed) -> ExternResult<()> {
match action.hashed.content.clone() {
Action::CreateLink(create_link) => {
if let Ok(Some(link_type)) =
LinkTypes::from_type(create_link.zome_index, create_link.link_type)
{
emit_signal(Signal::LinkCreated { action, link_type })?;
}
Ok(())
}
Action::DeleteLink(delete_link) => {
let record =
get(delete_link.link_add_address, GetOptions::default())?.ok_or(wasm_error!(
WasmErrorInner::Guest("Failed to fetch CreateLink action".to_string())
))?;
match record.action() {
Action::CreateLink(create_link) => {
if let Ok(Some(link_type)) =
LinkTypes::from_type(create_link.zome_index, create_link.link_type)
{
emit_signal(Signal::LinkDeleted { action, link_type })?;
}
Ok(())
}
_ => Err(wasm_error!(WasmErrorInner::Guest(
"Create Link should exist".to_string()
))),
}
}
_ => Ok(()),
}
}

0 comments on commit 8113b81

Please sign in to comment.