Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Consistently name these 'ops'
Alexis Sellier committed 3 years ago
commit de0e54a186f3b7fa4116b5d39d4cef556dcf64e3
parent 56f9af650e24f5077f6ff24ea21148152415bbae
3 files changed +22 -23
modified radicle/src/cob/issue.rs
@@ -112,8 +112,8 @@ impl store::FromHistory for Issue {
        history: &radicle_cob::History,
    ) -> Result<(Self, clock::Lamport), store::Error> {
        let obj = history.traverse(Self::default(), |mut acc, entry| {
-
            if let Ok(Ops(changes)) = Ops::try_from(entry) {
-
                if let Err(err) = acc.apply(changes) {
+
            if let Ok(Ops(ops)) = Ops::try_from(entry) {
+
                if let Err(err) = acc.apply(ops) {
                    log::warn!("Error applying op to issue state: {err}");
                    return ControlFlow::Break(acc);
                }
@@ -155,29 +155,29 @@ impl Issue {
        self.thread.comments().map(|(id, comment)| (id, comment))
    }

-
    pub fn apply(&mut self, changes: impl IntoIterator<Item = Op>) -> Result<(), Error> {
-
        for change in changes {
-
            match change.action {
+
    pub fn apply(&mut self, ops: impl IntoIterator<Item = Op>) -> Result<(), Error> {
+
        for op in ops {
+
            match op.action {
                Action::Title { title } => {
-
                    self.title.set(title, change.clock);
+
                    self.title.set(title, op.clock);
                }
                Action::Lifecycle { status } => {
-
                    self.status.set(status, change.clock);
+
                    self.status.set(status, op.clock);
                }
                Action::Tag { add, remove } => {
                    for tag in add {
-
                        self.tags.insert(tag, change.clock);
+
                        self.tags.insert(tag, op.clock);
                    }
                    for tag in remove {
-
                        self.tags.remove(tag, change.clock);
+
                        self.tags.remove(tag, op.clock);
                    }
                }
                Action::Thread { action } => {
                    self.thread.apply([cob::Op {
                        action,
-
                        author: change.author,
-
                        clock: change.clock,
-
                        timestamp: change.timestamp,
+
                        author: op.author,
+
                        clock: op.clock,
+
                        timestamp: op.timestamp,
                    }]);
                }
            }
modified radicle/src/cob/patch.rs
@@ -329,8 +329,8 @@ impl store::FromHistory for Patch {
        history: &radicle_cob::History,
    ) -> Result<(Self, clock::Lamport), store::Error> {
        let obj = history.traverse(Self::default(), |mut acc, entry| {
-
            if let Ok(Ops(changes)) = Ops::try_from(entry) {
-
                if let Err(err) = acc.apply(changes) {
+
            if let Ok(Ops(ops)) = Ops::try_from(entry) {
+
                if let Err(err) = acc.apply(ops) {
                    log::warn!("Error applying op to patch state: {err}");
                    return ControlFlow::Break(acc);
                }
modified radicle/src/cob/thread.rs
@@ -167,14 +167,13 @@ impl Thread {
            .map(|(a, r)| (a, r))
    }

-
    pub fn apply(&mut self, changes: impl IntoIterator<Item = Op<Action>>) {
-
        for change in changes.into_iter() {
-
            let id = change.id();
+
    pub fn apply(&mut self, ops: impl IntoIterator<Item = Op<Action>>) {
+
        for op in ops.into_iter() {
+
            let id = op.id();

-
            match change.action {
+
            match op.action {
                Action::Comment { body, reply_to } => {
-
                    let present =
-
                        Redactable::Present(Comment::new(body, reply_to, change.timestamp));
+
                    let present = Redactable::Present(Comment::new(body, reply_to, op.timestamp));
                    self.comments.insert(id, present);
                }
                Action::Redact { id } => {
@@ -185,12 +184,12 @@ impl Thread {
                    reaction,
                    active,
                } => {
-
                    let key = (change.author, reaction);
+
                    let key = (op.author, reaction);
                    let reactions = if active {
-
                        LWWSet::singleton(key, change.clock)
+
                        LWWSet::singleton(key, op.clock)
                    } else {
                        let mut set = LWWSet::default();
-
                        set.remove(key, change.clock);
+
                        set.remove(key, op.clock);
                        set
                    };
                    self.reactions.insert(to, reactions);