private void UpdateItems()
        {
            if (_once)
            {
                return;
            }
            var channel = CurrentItem as TLChannel;

            if (channel == null)
            {
                return;
            }

            IsWorking = true;
            Status    = Items.Count > 0 ? string.Empty : AppResources.Loading;
            MTProtoService.GetParticipantsAsync(channel.ToInputChannel(), new TLChannelParticipantsRecent(), new TLInt(0), new TLInt(200),
                                                result => Execute.BeginOnUIThread(() =>
            {
                _once     = true;
                IsWorking = false;
                Items.Clear();
                foreach (var user in result.Users)
                {
                    Items.Add(user);
                }
                Status = Items.Count > 0 ? string.Empty : AppResources.NoUsersHere;
            }),
                                                error => Execute.BeginOnUIThread(() =>
            {
                IsWorking = false;
                Status    = string.Empty;

                Execute.ShowDebugMessage("channels.getParticipants error " + error);
            }));
        }
Exemplo n.º 2
0
        private void UpdateChannelItems(TLChannel channel)
        {
            IsWorking = true;
            MTProtoService.GetParticipantsAsync(channel.ToInputChannel(), new TLChannelParticipantsRecent(), new TLInt(0), new TLInt(32),
                                                result => Execute.BeginOnUIThread(() =>
            {
                IsWorking = false;
                Items.Clear();
                foreach (var user in result.Users)
                {
                    Items.Add(user);
                }
                Status = Items.Count > 0 ? string.Empty : AppResources.NoUsersHere;
            }),
                                                error => Execute.BeginOnUIThread(() =>
            {
                IsWorking = false;
                Status    = string.Empty;

                Execute.ShowDebugMessage("channels.getParticipants error " + error);
            }));
        }
        private void SearchUser(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                var users = GetChatUsers();
                SearchMessages.Hints.Clear();
                foreach (var user in users)
                {
                    SearchMessages.Hints.Add(user);
                }

                return;
            }

            var channel = With as TLChannel;

            if (channel == null || !channel.IsMegaGroup)
            {
                return;
            }

            if (SearchMessages.From != null)
            {
                return;
            }
            var key = GetKey(text, SearchMessages.Date, SearchMessages.From);

            //System.Diagnostics.Debug.WriteLine("key=" + key);

            BeginOnUIThread(TimeSpan.FromSeconds(0.25), () =>
            {
                if (SearchMessages.From != null)
                {
                    return;
                }
                var currentKey = GetKey(SearchMessages.Text, SearchMessages.Date, SearchMessages.From);
                //System.Diagnostics.Debug.WriteLine("current_key=" + currentKey + " key=" + key);
                if (!string.Equals(key, currentKey))
                {
                    return;
                }

                System.Diagnostics.Debug.WriteLine("channel.getPartisipants q=" + text);
                MTProtoService.GetParticipantsAsync(
                    channel.ToInputChannel(),
                    new TLChannelParticipantsSearch {
                    Q = new TLString(text)
                },
                    new TLInt(0),
                    new TLInt(50),
                    new TLInt(0),
                    result => Execute.BeginOnUIThread(() =>
                {
                    var channelParticipants = result as TLChannelParticipants;
                    if (channelParticipants != null)
                    {
                        currentKey = GetKey(SearchMessages.Text, SearchMessages.Date, SearchMessages.From);
                        //System.Diagnostics.Debug.WriteLine("channel.getPartisipants q=" + text + " results=" + result.Users.Count + " current_key=" + currentKey);
                        if (!string.Equals(key, currentKey))
                        {
                            return;
                        }

                        SearchMessages.Hints.Clear();
                        foreach (var user in channelParticipants.Users)
                        {
                            SearchMessages.Hints.Add(user);
                        }
                    }
                }),
                    error => Execute.BeginOnUIThread(() =>
                {
                    currentKey = GetKey(SearchMessages.Text, SearchMessages.Date, SearchMessages.From);
                    //System.Diagnostics.Debug.WriteLine("channel.getPartisipants q=" + text + " error current_key=" + currentKey);
                    if (!string.Equals(key, currentKey))
                    {
                        return;
                    }

                    SearchMessages.Hints.Clear();
                }));
            });
        }
        protected override void OnInitialize()
        {
            if (Channel == null)
            {
                return;
            }

            //Status = AppResources.Loading;
            IsWorking = true;
            MTProtoService.GetParticipantsAsync(Channel.ToInputChannel(), new TLChannelParticipantsKicked68 {
                Q = TLString.Empty
            }, new TLInt(0), new TLInt(100), new TLInt(0),
                                                result =>
            {
                var channelParticipants = result as TLChannelParticipants;
                if (channelParticipants != null)
                {
                    var kickedParticipants = new Dictionary <int, int>();
                    foreach (var participant in channelParticipants.Participants)
                    {
                        var kickedParticipant = participant as TLChannelParticipantBanned;
                        if (kickedParticipant != null)
                        {
                            kickedParticipants[kickedParticipant.UserId.Value] = kickedParticipant.UserId.Value;
                        }
                    }

                    var contacts = channelParticipants;
                    foreach (var user in contacts.Users)
                    {
                        if (kickedParticipants.ContainsKey(user.Index))
                        {
                            var cachedUser = CacheService.GetUser(new TLInt(user.Index));
                            if (cachedUser != null)
                            {
                                LazyItems.Add(cachedUser);
                            }
                            else
                            {
                                LazyItems.Add(user);
                            }
                        }
                    }

                    BeginOnUIThread(() =>
                    {
                        IsWorking   = false;
                        IsEmptyList = Items.Count == 0 && LazyItems.Count == 0;
                        Status      = string.Empty;
                        PopulateItems();
                    });
                }
            },
                                                error => BeginOnUIThread(() =>
            {
                IsWorking = false;
                Status    = string.Empty;
            }));

            base.OnInitialize();
        }