Exemple #1
0
        public void Handle(ChannelAvailableMessagesEventArgs args)
        {
            if (With == args.Dialog.With)
            {
                BeginOnUIThread(() =>
                {
                    var groups = new Dictionary <long, Tuple <TLMessage, GroupedMessages> >();

                    for (var i = 0; i < Items.Count; i++)
                    {
                        var messageCommon = Items[i] as TLMessageCommonBase;
                        if (messageCommon != null && messageCommon.ToId is TLPeerChannel && messageCommon.Id <= args.AvailableMinId)
                        {
                            if (messageCommon is TLMessage grouped && grouped.HasGroupedId && grouped.GroupedId is long groupedId && _groupedMessages.TryGetValue(groupedId, out TLMessage group) && group.Media is TLMessageMediaGroup groupMedia)
                            {
                                groupMedia.Layout.Messages.Remove(grouped);
                                groups[groupedId] = Tuple.Create(group, groupMedia.Layout);
                            }
                        }
                    }

                    foreach (var group in groups.Values)
                    {
                        if (group.Item2.Messages.Count > 0)
                        {
                            group.Item2.Calculate();
                            group.Item1.RaisePropertyChanged(() => group.Item1.Self);
                        }
                        else
                        {
                            _groupedMessages.TryRemove(group.Item2.GroupedId, out TLMessage removed);
                            Items.Remove(group.Item1);
                        }
                    }

                    for (var i = 0; i < Items.Count; i++)
                    {
                        var messageCommon = Items[i] as TLMessageCommonBase;
                        if (messageCommon != null && messageCommon.ToId is TLPeerChannel && messageCommon.Id <= args.AvailableMinId)
                        {
                            Items.RemoveAt(i--);
                        }
                    }

                    //IsEmpty = Items.Count == 0 && (_messages == null || _messages.Count == 0) && LazyItems.Count == 0;
                });
            }
        }
Exemple #2
0
        public void Handle(ChannelAvailableMessagesEventArgs args)
        {
            if (With == args.Dialog.With)
            {
                Execute.BeginOnUIThread(() =>
                {
                    for (var i = 0; i < Items.Count; i++)
                    {
                        var messageCommon = Items[i] as TLMessageCommonBase;
                        if (messageCommon != null && messageCommon.ToId is TLPeerChannel && messageCommon.Id <= args.AvailableMinId)
                        {
                            Items.RemoveAt(i--);
                        }
                    }

                    //IsEmpty = Items.Count == 0 && (_messages == null || _messages.Count == 0) && LazyItems.Count == 0;
                });
            }
        }