mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-03 18:50:30 +08:00
Return comments and replies instead of Oids
This commit is contained in:
Generated
+1
@@ -3992,6 +3992,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"localtime",
|
||||
"log",
|
||||
"radicle",
|
||||
"radicle-surf",
|
||||
|
||||
@@ -18,6 +18,7 @@ tauri-build = { version = "2.0.1", features = ["isolation"] }
|
||||
anyhow = { version = "1.0.90" }
|
||||
base64 = { version = "0.22.1" }
|
||||
log = { version = "0.4.22" }
|
||||
localtime = { version = "1.3.1" }
|
||||
radicle = { git = "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git" }
|
||||
radicle-surf = { version = "0.22.1", features = ["serde"] }
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Author } from "./Author";
|
||||
import type { Edit } from "./Edit";
|
||||
import type { Never } from "./Never";
|
||||
import type { Reaction } from "./Reaction";
|
||||
|
||||
export type Comment<T = Never> = {
|
||||
export type Comment<T> = {
|
||||
id: string;
|
||||
author: Author;
|
||||
edits: Array<Edit>;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use radicle::git::Oid;
|
||||
use localtime::LocalTime;
|
||||
|
||||
use radicle::cob;
|
||||
use radicle::identity;
|
||||
use radicle::node::Handle;
|
||||
use radicle::storage::ReadStorage;
|
||||
@@ -15,7 +17,8 @@ pub fn create_issue_comment(
|
||||
rid: identity::RepoId,
|
||||
new: thread::NewIssueComment,
|
||||
opts: cobs::CobOptions,
|
||||
) -> Result<Oid, Error> {
|
||||
) -> Result<thread::Comment<cobs::Never>, Error> {
|
||||
let aliases = &ctx.profile.aliases();
|
||||
let mut node = Node::new(ctx.profile.socket());
|
||||
let signer = ctx.profile.signer()?;
|
||||
let repo = ctx.profile.storage.repository(rid)?;
|
||||
@@ -25,13 +28,24 @@ pub fn create_issue_comment(
|
||||
let (root_id, _) = issue.root();
|
||||
*root_id
|
||||
});
|
||||
let oid = issue.comment(new.body, id, new.embeds, &signer)?;
|
||||
let oid = issue.comment(new.body.clone(), id, new.embeds.clone(), &signer)?;
|
||||
|
||||
if opts.announce() {
|
||||
node.announce_refs(rid)?;
|
||||
}
|
||||
|
||||
Ok::<_, Error>(oid)
|
||||
Ok(thread::Comment::<cobs::Never>::new(
|
||||
oid,
|
||||
cob::thread::Comment::new(
|
||||
*signer.public_key(),
|
||||
new.body,
|
||||
id.into(),
|
||||
None,
|
||||
new.embeds,
|
||||
LocalTime::now().into(),
|
||||
),
|
||||
aliases,
|
||||
))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -40,18 +54,20 @@ pub fn create_patch_comment(
|
||||
rid: identity::RepoId,
|
||||
new: thread::NewPatchComment,
|
||||
opts: cobs::CobOptions,
|
||||
) -> Result<Oid, Error> {
|
||||
) -> Result<thread::Comment<thread::CodeLocation>, Error> {
|
||||
let aliases = &ctx.profile.aliases();
|
||||
let mut node = Node::new(ctx.profile.socket());
|
||||
let signer = ctx.profile.signer()?;
|
||||
let repo = ctx.profile.storage.repository(rid)?;
|
||||
let mut patches = ctx.profile.patches_mut(&repo)?;
|
||||
let mut patch = patches.get_mut(&new.id.into())?;
|
||||
let n = new.clone();
|
||||
let oid = patch.comment(
|
||||
new.revision.into(),
|
||||
new.body,
|
||||
new.reply_to,
|
||||
new.location.map(|l| l.into()),
|
||||
new.embeds,
|
||||
n.body,
|
||||
n.reply_to,
|
||||
n.location.map(|l| l.into()),
|
||||
n.embeds,
|
||||
&signer,
|
||||
)?;
|
||||
|
||||
@@ -59,5 +75,16 @@ pub fn create_patch_comment(
|
||||
node.announce_refs(rid)?;
|
||||
}
|
||||
|
||||
Ok::<_, Error>(oid)
|
||||
Ok(thread::Comment::<thread::CodeLocation>::new(
|
||||
oid,
|
||||
cob::thread::Comment::new(
|
||||
*signer.public_key(),
|
||||
new.body,
|
||||
new.reply_to,
|
||||
new.location.map(|l| l.into()),
|
||||
new.embeds,
|
||||
LocalTime::now().into(),
|
||||
),
|
||||
aliases,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use radicle::node::{Alias, AliasStore};
|
||||
use radicle::patch;
|
||||
use radicle::storage::git;
|
||||
|
||||
use crate::types::cobs;
|
||||
use crate::types::thread;
|
||||
|
||||
#[derive(Serialize, TS)]
|
||||
@@ -45,7 +46,7 @@ pub struct Issue {
|
||||
#[ts(type = "{ status: 'closed', reason: 'other' | 'solved' } | { status: 'open' } ")]
|
||||
state: issue::State,
|
||||
assignees: Vec<Author>,
|
||||
discussion: Vec<thread::Comment>,
|
||||
discussion: Vec<thread::Comment<cobs::Never>>,
|
||||
#[ts(as = "Vec<String>")]
|
||||
labels: Vec<cob::Label>,
|
||||
#[ts(type = "number")]
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct CreateReviewComment {
|
||||
|
||||
#[derive(Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Comment<T = cobs::Never> {
|
||||
pub struct Comment<T> {
|
||||
#[ts(as = "String")]
|
||||
id: cob::thread::CommentId,
|
||||
author: cobs::Author,
|
||||
@@ -65,7 +65,7 @@ impl Comment<CodeLocation> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Comment {
|
||||
impl Comment<cobs::Never> {
|
||||
pub fn new(
|
||||
id: cob::thread::CommentId,
|
||||
comment: cob::thread::Comment,
|
||||
@@ -91,7 +91,7 @@ impl Comment {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(TS, Serialize, Deserialize)]
|
||||
#[derive(Clone, TS, Serialize, Deserialize)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NewIssueComment {
|
||||
@@ -105,7 +105,7 @@ pub struct NewIssueComment {
|
||||
pub embeds: Vec<cob::Embed<cob::Uri>>,
|
||||
}
|
||||
|
||||
#[derive(TS, Serialize, Deserialize)]
|
||||
#[derive(Clone, TS, Serialize, Deserialize)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NewPatchComment {
|
||||
@@ -122,7 +122,7 @@ pub struct NewPatchComment {
|
||||
pub embeds: Vec<cob::Embed<cob::Uri>>,
|
||||
}
|
||||
|
||||
#[derive(TS, Serialize, Deserialize)]
|
||||
#[derive(Clone, TS, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
pub struct CodeLocation {
|
||||
@@ -166,7 +166,7 @@ impl From<CodeLocation> for cob::CodeLocation {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(TS, Serialize, Deserialize)]
|
||||
#[derive(Clone, TS, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", tag = "type")]
|
||||
#[ts(export)]
|
||||
pub enum CodeRange {
|
||||
|
||||
Reference in New Issue
Block a user