From facb4573c3f1f10b5ed7681c85cbb267e63b5cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Enclos?= Date: Tue, 4 Dec 2018 10:48:22 +0100 Subject: [PATCH] fix(lsstate): fix fromPlain method --- src/CrdtImpl/LogootSplit/LSState.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/CrdtImpl/LogootSplit/LSState.ts b/src/CrdtImpl/LogootSplit/LSState.ts index e64729c..b67fc2c 100644 --- a/src/CrdtImpl/LogootSplit/LSState.ts +++ b/src/CrdtImpl/LogootSplit/LSState.ts @@ -1,21 +1,20 @@ -import { LogootSOperation, LogootSRopes } from "mute-structs"; -import { SafeAny } from "safe-any"; -import { State, StateJSON } from "../../core"; -import { generateId } from "../../misc"; -import { LSRichOperation } from "./LSRichOperation"; +import { LogootSOperation, LogootSRopes } from 'mute-structs' +import { SafeAny } from 'safe-any' +import { State, StateJSON } from '../../core' +import { generateId } from '../../misc' +import { LSRichOperation } from './LSRichOperation' export class LSState extends State { - - static emptyState (): LSState { + static emptyState(): LSState { const id = generateId() return new LSState(id, new LogootSRopes(id), [], new Map(), 0) } - static fromPlain (o: SafeAny>): LSState | null { - if (o !== null && typeof o === 'object' && o.richOps instanceof Array) { + static fromPlain(o: SafeAny>): LSState | null { + if (o !== null && typeof o === 'object' && o.remoteOperations instanceof Array) { // If one operation is null -> error - const lsRichOperations = o.richOps.map((rich) => { - return LSRichOperation.fromPlain(rich) + const lsRichOperations = o.remoteOperations.map((richOp) => { + return LSRichOperation.fromPlain(richOp) }) as LSRichOperation[] const nbOperationNull = lsRichOperations.filter((r) => r === null).length if (nbOperationNull > 0) { @@ -68,4 +67,4 @@ export class LSState extends State { } return null } -} \ No newline at end of file +}