Skip to content

Commit

Permalink
fix(lsrichoperation): fix fromPlain method
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricenclos committed Dec 4, 2018
1 parent facb457 commit 976d9c8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/CrdtImpl/LogootSplit/LSRichOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ export class LSRichOperation extends RichOperation<LogootSOperation> {
typeof o.id === 'number' &&
Number.isInteger(o.id) &&
typeof o.clock === 'number' &&
Number.isInteger(o.clock) &&
o.dependencies instanceof Map
Number.isInteger(o.clock)
) {
const logootSAdd = LogootSAdd.fromPlain(o.operation)
if (logootSAdd instanceof LogootSAdd) {
return new LSRichOperation(o.id, o.clock, logootSAdd)
}

const logootSDel = LogootSDel.fromPlain(o.operation)
if (logootSDel instanceof LogootSDel && o.dependencies.size > 0) {
return new LSRichOperation(o.id, o.clock, logootSDel, new Map(o.dependencies))
if (logootSDel instanceof LogootSDel) {
if (o.dependencies instanceof Array && o.dependencies.length > 0) {
return new LSRichOperation(o.id, o.clock, logootSDel, new Map(o.dependencies))
} else if (o.dependencies instanceof Map && o.dependencies.size > 0) {
return new LSRichOperation(o.id, o.clock, logootSDel, o.dependencies)
}
}
}
return null
Expand Down

0 comments on commit 976d9c8

Please sign in to comment.