private void UpdateItemsAsync()
        {
            _isGettingContacts = true;
            //IsWorking = true;
            var contactIds = string.Join(",", Items.Select(x => x.Index).OrderBy(x => x));
            var hash       = MD5Core.GetHash(contactIds);
            var hashString = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();

            MTProtoService.GetContactsAsync(new TLString(hashString),
                                            result =>
            {
                _isGettingContacts = false;

                //IsWorking = false;
                if (result is TLContactsNotModified)
                {
                    return;
                }

                InsertContacts(((TLContacts)result).Users, false);
            },
                                            error =>
            {
                _isGettingContacts = false;
                //IsWorking = false;
            });
        }
Beispiel #2
0
        public void GetContactsAsync(System.Action callback)
        {
            var savedCount = TLUtils.OpenObjectFromMTProtoFile <TLInt>(_savedCountSyncRoot, Constants.SavedCountFileName);
            var hash       = TLUtils.GetContactsHash(savedCount, CacheService.GetContacts().Where(x => x.IsContact).OrderBy(x => x.Index).ToList());

            IsWorking = true;
            MTProtoService.GetContactsAsync(new TLInt(hash),
                                            result => Execute.BeginOnUIThread(() =>
            {
                Execute.ShowDebugMessage(result.ToString());

                IsWorking    = false;
                var contacts = result as TLContacts71;
                if (contacts != null)
                {
                    TLUtils.SaveObjectToMTProtoFile(_savedCountSyncRoot, Constants.SavedCountFileName, contacts.SavedCount);
                    InsertContacts(contacts.Users);
                }

                var contactsNotModified = result as TLContactsNotModified;
                if (contactsNotModified != null)
                {
                }

                callback.SafeInvoke();
            }),
                                            error => Execute.BeginOnUIThread(() =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("contacts.getContacts error: " + error);

                callback.SafeInvoke();
            }));
        }
Beispiel #3
0
        public void GetContactsAsync()
        {
            var contactIds = string.Join(",", Items.Select(x => x.Index).Union(new [] { StateService.CurrentUserId }).OrderBy(x => x));
            var hash       = MD5Core.GetHash(contactIds);
            var hashString = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();

            IsWorking = true;
            MTProtoService.GetContactsAsync(new TLString(hashString),
                                            result =>
            {
                IsWorking    = false;
                var contacts = result as TLContacts;
                if (contacts != null)
                {
                    InsertContacts(contacts.Users, false);
                }
            },
                                            error =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("contacts.getContacts error: " + error);
            });
        }