public void UpdateStroke(string id, StrokeModel stroke) { if (stroke != null) { stroke.AuthorId = AuthService.CurrentUser?.Id ?? AuthService.OfflineClientId; stroke.LastModificationDate = DateTime.Now; Logger.Debug($"Adding stroke ${id}"); if (IsOffline) { StrokesMap[id] = stroke; } } else { Logger.Debug($"Removing stroke ${id}"); if (IsOffline) { StrokeModel _; StrokesMap.TryRemove(id, out _); } } StrokesToUpdate[id] = stroke; StrokesMapOverride[id] = stroke; if (IsOffline) { StrokesUpdated?.Invoke(); } }
/// <summary> /// Merges the strokes map with the strokes map override to give the most recent strokes list available. /// </summary> public StrokeModelsList GetMergedStrokeMaps() { StrokeModel _; foreach (var stroke in StrokesMapOverride) { if (stroke.Value == null) { StrokesMap.TryRemove(stroke.Key, out _); } else { StrokesMap[stroke.Key] = stroke.Value; } } var strokes = StrokesMap.Select(x => x.Value).ToList(); strokes.Sort((x, y) => DateTime.Compare(x.CreatedDate, y.CreatedDate)); return(strokes); }