コード例 #1
0
        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();
            }
        }
コード例 #2
0
        private async Task PullStrokes()
        {
            if (IsOffline)
            {
                StrokesMap = Cache.Get <ConcurrentDictionary <string, StrokeModel> >(DatabasePaths.Strokes, DrawingId) ?? new StrokeModelsMap();
#pragma warning disable CS4014
                Task.Run(() =>
                {
                    Thread.Sleep(100);
                    StrokesUpdated?.Invoke();
                });
#pragma warning restore CS4014
            }
            else
            {
                StrokesMap = await DatabaseService.Ref(DatabasePaths.Strokes).Child(DrawingId).Once <StrokeModelsMap>();
            }
        }
コード例 #3
0
 private void SyncRemoteStrokesToLocal(StrokeModelsMap strokes)
 {
     StrokesMap = strokes;
     PurgeOverrideMap();
     StrokesUpdated?.Invoke();
 }