Skip to content

Commit

Permalink
Avoid announcing changes when node is stopped
Browse files Browse the repository at this point in the history
Also in the edge case that the frontend didn't update and the node just
stopped in between we fallback gracefully instead of returning an error
on the backend.
  • Loading branch information
sebastinez committed Dec 5, 2024
1 parent 5c8844d commit f9fb616
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion crates/radicle-types/src/traits/issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ pub trait IssuesMut: Profile {
)?;

if opts.announce() {
node.announce_refs(rid)?;
if let Err(e) = node.announce_refs(rid) {
eprintln!("Not able to announce changes: {}", e)
}
}

Ok::<_, Error>(cobs::issue::Issue::new(issue.id(), &issue, &aliases))
Expand Down
8 changes: 6 additions & 2 deletions crates/radicle-types/src/traits/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ pub trait Thread: Profile {
)?;

if opts.announce() {
node.announce_refs(rid)?;
if let Err(e) = node.announce_refs(rid) {
eprintln!("Not able to announce changes: {}", e)
}
}

Ok(cobs::thread::Comment::<cobs::Never>::new(
Expand Down Expand Up @@ -102,7 +104,9 @@ pub trait Thread: Profile {
)?;

if opts.announce() {
node.announce_refs(rid)?;
if let Err(e) = node.announce_refs(rid) {
eprintln!("Not able to announce changes: {}", e)
}
}

Ok(cobs::thread::Comment::<cobs::thread::CodeLocation>::new(
Expand Down
13 changes: 7 additions & 6 deletions src/views/repo/Issue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import Layout from "./Layout.svelte";
import Sidebar from "@app/components/Sidebar.svelte";
import { nodeRunning } from "@app/lib/events";
interface Props {
repo: RepoInfo;
Expand Down Expand Up @@ -113,7 +114,7 @@
await invoke("create_issue_comment", {
rid: repo.rid,
new: { id: issue.id, body, embeds },
opts: { announce: $announce },
opts: { announce: $nodeRunning && $announce },
});
// Update second column issue comment count without reloading the whole
// issue list.
Expand All @@ -133,7 +134,7 @@
await invoke("create_issue_comment", {
rid: repo.rid,
new: { id: issue.id, body, embeds, replyTo },
opts: { announce: $announce },
opts: { announce: $nodeRunning && $announce },
});
// Update second column issue comment count without reloading the whole
// issue list.
Expand All @@ -159,7 +160,7 @@
body,
embeds,
},
opts: { announce: $announce },
opts: { announce: $nodeRunning && $announce },
});
} catch (error) {
console.error("Issue comment editing failed: ", error);
Expand All @@ -183,7 +184,7 @@
id,
title,
},
opts: { announce: $announce },
opts: { announce: $nodeRunning && $announce },
});
// Update second column issue title without reloading the whole issue list.
const issueIndex = issues.findIndex(i => i.id === issue.id);
Expand Down Expand Up @@ -216,7 +217,7 @@
({ did }) => publicKeyFromDid(did) === publicKey,
),
},
opts: { announce: $announce },
opts: { announce: $nodeRunning && $announce },
});
} catch (error) {
console.error("Editing reactions failed", error);
Expand All @@ -234,7 +235,7 @@
type: "lifecycle",
state,
},
opts: { announce: $announce },
opts: { announce: $nodeRunning && $announce },
});
// Update second column issue icon without reloading the whole issue list.
const issueIndex = issues.findIndex(i => i.id === issue.id);
Expand Down

0 comments on commit f9fb616

Please sign in to comment.