Exemple #1
0
        public static UnifiedBubbleGroup CreateUnified(List <BubbleGroup> groups, BubbleGroup primaryGroup)
        {
            lock (BubbleGroupDatabase.OperationLock)
            {
                var unifiedGroupsToKill = new HashSet <UnifiedBubbleGroup>();
                foreach (var group in groups)
                {
                    if (group.IsUnified)
                    {
                        unifiedGroupsToKill.Add(group.Unified);
                        @group.DeregisterUnified();
                    }
                }
                foreach (var unifiedGroup in unifiedGroupsToKill)
                {
                    BubbleGroupManager.BubbleGroupsRemove(unifiedGroup);
                }
                BubbleGroupIndex.RemoveUnified(unifiedGroupsToKill.Select(x => x.ID).ToArray());

                var unified = CreateUnifiedInternal(groups, primaryGroup);
                BubbleGroupIndex.AddUnified(unified);
                BubbleGroupManager.BubbleGroupsAdd(unified);
                BubbleGroupSettingsManager.SetUnreadIndicatorGuid(unified, unified.LastBubbleSafe().ID, false);
                return(unified);
            }
        }
Exemple #2
0
        public static List <BubbleGroup> DeleteUnified(UnifiedBubbleGroup unifiedGroup, bool deleteInnerGroups = true)
        {
            lock (BubbleGroupDatabase.OperationLock)
            {
                foreach (var group in unifiedGroup.Groups)
                {
                    @group.DeregisterUnified();
                    if (deleteInnerGroups)
                    {
                        Delete(@group);
                    }
                }

                BubbleGroupManager.BubbleGroupsRemove(unifiedGroup);
                BubbleGroupIndex.RemoveUnified(unifiedGroup.ID);

                return(deleteInnerGroups ? null : unifiedGroup.Groups);
            }
        }