private static void Block(BigDB bigDb, string userId, string blockId, bool block, string blockProp, Callback callback) { bigDb.LoadOrCreate(BlockingTable, userId, blockingTable => { var blockingObject = blockingTable.GetObject(blockProp); if (blockingObject == null) { blockingObject = new DatabaseObject(); blockingTable.Set(blockProp, blockingObject); } if (block) { blockingObject.Set(blockId, true); } else { blockingObject.Remove(blockId); } blockingTable.Save(); callback(); }); }
public static void DismissNotification(BigDB bigDb, string connectUserId, string notificationId, EENotification[] ignoreList) { var ignoreIds = ignoreList.Select(i => i.Key).ToArray(); bigDb.LoadOrCreate("Dismisses", connectUserId, obj => { if (!obj.Contains("Notifications")) { obj.Set("Notifications", new DatabaseArray()); } var notifications = obj.GetArray("Notifications"); notifications.Add(notificationId); // remove all unused notifications for (var i = 0; i < notifications.Count; i++) { if (!ignoreIds.Contains(notifications[0])) { notifications.RemoveAt(i); } } obj.Save(); }); }
public static void BlockAll(BigDB bigDb, string userId, bool block, string blockProp) { bigDb.LoadOrCreate(BlockingTable, userId, blockingTable => { blockingTable.Set(blockProp, block); blockingTable.Save(); }); }
public static void AddSubscription(BigDB bigDb, string connectUserId, string channel, Callback <bool> callback = null) { bigDb.LoadOrCreate("Subscriptions", connectUserId, obj => { if (!obj.GetBool(channel, false)) { obj.Set(channel, true); obj.Save(); if (callback != null) { callback.Invoke(true); } } else { if (callback != null) { callback.Invoke(false); } } }); }