cob: Consistently name these 'ops'
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
56f9af650e
commit
de0e54a186
|
|
@ -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,
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue