diff --git a/ron-rdt/CHANGELOG.md b/ron-rdt/CHANGELOG.md index 95f76bbd..b213809e 100644 --- a/ron-rdt/CHANGELOG.md +++ b/ron-rdt/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0) and this project adheres to [Compatible Versioning](https://github.com/staltz/comver). +## [0.12.1] - 2026-03-16 +* Added some duplicate operation removal to `vertexListFromOps` +* Changed `applyPatch` to prefer new operations over existing ones when + updating the `HashMap UUID VertexListItem`. + ## [0.12] - 2022-03-11 - Added `Editable` typeclass which generalizes RON.Data.RGA.edit diff --git a/ron-rdt/lib/RON/Data/LWW.hs b/ron-rdt/lib/RON/Data/LWW.hs index 5387f3e6..a2099e0d 100644 --- a/ron-rdt/lib/RON/Data/LWW.hs +++ b/ron-rdt/lib/RON/Data/LWW.hs @@ -9,6 +9,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} -- | LWW-per-field RDT module RON.Data.LWW ( diff --git a/ron-rdt/lib/RON/Data/ORSet/Experimental.hs b/ron-rdt/lib/RON/Data/ORSet/Experimental.hs index d8864232..31d6cb31 100644 --- a/ron-rdt/lib/RON/Data/ORSet/Experimental.hs +++ b/ron-rdt/lib/RON/Data/ORSet/Experimental.hs @@ -5,6 +5,7 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} module RON.Data.ORSet.Experimental ( ORSet, diff --git a/ron-rdt/lib/RON/Data/RGA.hs b/ron-rdt/lib/RON/Data/RGA.hs index 75a70b30..58cf3cbe 100644 --- a/ron-rdt/lib/RON/Data/RGA.hs +++ b/ron-rdt/lib/RON/Data/RGA.hs @@ -48,6 +48,7 @@ import qualified Data.HashMap.Strict as HashMap import Data.Map.Strict ((!?)) import qualified Data.Map.Strict as Map import qualified Data.Text as Text +import Data.List (nubBy) import RON.Data.Internal (MonadObjectState, Editable (..), @@ -119,7 +120,7 @@ vertexListToOps v@VertexList {..} = go listHead listItems in itemValue : rest vertexListFromOps :: [Vertex] -> Maybe VertexList -vertexListFromOps = foldr go mempty +vertexListFromOps = foldr go mempty . nubBy (\Op{opId = opIdA} Op{opId = opIdB} -> opIdA == opIdB) where go v@Op{opId} vlist = Just VertexList{listHead = opId, listItems = vlist'} where @@ -276,7 +277,7 @@ applyPatch parent patch targetItems = case parent of Nothing -> patch Just next -> VertexList next targetItems <> patch let item' = item {itemNext = Just next'} - pure $ HashMap.insert parent item' targetItems <> newItems + pure $ HashMap.insert parent item' newItems <> targetItems reapplyRemovalsToState :: (RgaRep, PatchSet) -> Maybe (RgaRep, PatchSet) reapplyRemovalsToState (RgaRep rstate, ps@PatchSet {..}) = do diff --git a/ron-rdt/ron-rdt.cabal b/ron-rdt/ron-rdt.cabal index ceb17b46..7f6c9b85 100644 --- a/ron-rdt/ron-rdt.cabal +++ b/ron-rdt/ron-rdt.cabal @@ -1,7 +1,7 @@ cabal-version: 2.2 name: ron-rdt -version: 0.10 +version: 0.12.1 bug-reports: https://github.com/ff-notes/ron/issues category: Distributed Systems, Protocol, Database