Esempio n. 1
0
        public void ClearRecent()
        {
            Recent.Clear();
            NotifyOfPropertyChange(() => ShowRecent);

            DeleteRecentAsync();
        }
        public void ForwardInAnimationComplete()
        {
            Telegram.Api.Helpers.Execute.BeginOnThreadPool(() =>
            {
                _recentResults = _recentResults ?? TLUtils.OpenObjectFromMTProtoFile <TLVector <TLResultInfo> >(_recentSyncRoot, Constants.RecentSearchResultsFileName) ?? new TLVector <TLResultInfo>();

                var recent = new List <TLObject>();
                foreach (var result in _recentResults)
                {
                    if (result.Type.ToString() == "user")
                    {
                        var user = _cacheService.GetUser(result.Id);
                        if (user != null)
                        {
                            recent.Add(user);
                            if (user.Dialog == null)
                            {
                                user.Dialog = _cacheService.GetDialog(new TLPeerUser {
                                    Id = user.Id
                                });
                            }
                        }
                    }

                    if (result.Type.ToString() == "chat")
                    {
                        var chat = _cacheService.GetChat(result.Id);
                        if (chat != null)
                        {
                            recent.Add(chat);
                            if (chat.Dialog == null)
                            {
                                chat.Dialog = _cacheService.GetDialog(new TLPeerChat {
                                    Id = chat.Id
                                });
                            }
                        }
                    }
                }

                Telegram.Api.Helpers.Execute.BeginOnUIThread(() =>
                {
                    if (!string.IsNullOrEmpty(Text))
                    {
                        return;
                    }

                    Recent.Clear();
                    foreach (var recentItem in recent)
                    {
                        Recent.Add(recentItem);
                    }

                    NotifyOfPropertyChange(() => ShowRecent);
                });
            });
        }
        public void ClearRecent()
        {
            Recent.Clear();
            NotifyOfPropertyChange(() => ShowRecent);

            Telegram.Api.Helpers.Execute.BeginOnThreadPool(() =>
            {
                var recentResults = new TLVector <TLResultInfo>();
                _recentResults    = recentResults;
                TLUtils.SaveObjectToMTProtoFile(_recentSyncRoot, Constants.RecentSearchResultsFileName, recentResults);
            });
        }