/// <returns>Whether the data was written.</returns> internal bool WriteUpdateMessageFromTransaction(IUpdateEncoder encoder) { if (DeleteSet.Clients.Count == 0 && !AfterState.Any(kvp => !BeforeState.TryGetValue(kvp.Key, out var clockB) || kvp.Value != clockB)) { return(false); } DeleteSet.SortAndMergeDeleteSet(); EncodingUtils.WriteClientsStructs(encoder, Doc.Store, BeforeState); DeleteSet.Write(encoder); return(true); }
/// <summary> /// If 'type.parent' was added in current transaction, 'type' technically did not change, /// it was just added and we should not fire events for 'type'. /// </summary> internal void AddChangedTypeToTransaction(AbstractType type, string parentSub) { var item = type._item; if (item == null || (BeforeState.TryGetValue(item.Id.Client, out int clock) && item.Id.Clock < clock && !item.Deleted)) { if (!Changed.TryGetValue(type, out var set)) { set = new HashSet <string>(); Changed[type] = set; } set.Add(parentSub); } }