Пример #1
0
        public void BlockContact()
        {
            if (CurrentContact == null)
            {
                return;
            }

            var confirmation = IsBot
                ? MessageBoxResult.OK
                : MessageBox.Show(AppResources.BlockContactConfirmation, AppResources.AppName, MessageBoxButton.OKCancel);

            if (confirmation == MessageBoxResult.OK)
            {
                IsWorking = true;
                MTProtoService.BlockAsync(CurrentContact.ToInputUser(),
                                          result => BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    CurrentContact.Blocked = TLBool.True;
                    CacheService.Commit();
                    EventAggregator.Publish(new TLUpdateUserBlocked {
                        UserId = CurrentContact.Id, Blocked = TLBool.True
                    });
                }),
                                          error => BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    Execute.ShowDebugMessage("contacts.block error " + error);
                }));
            }
        }
        public void DeleteContact()
        {
            if (CurrentContact == null)
            {
                return;
            }

            var messageBoxResult = MessageBox.Show(AppResources.ConfirmDeleteContact, AppResources.Confirm, MessageBoxButton.OKCancel);

            if (messageBoxResult != MessageBoxResult.OK)
            {
                return;
            }

            IsWorking = true;
            MTProtoService.DeleteContactAsync(
                CurrentContact.ToInputUser(),
                result =>
            {
                IsWorking = false;
                EventAggregator.Publish(result.User);
                RaiseImportStatusChanged(new ImportEventArgs {
                    Imported = false
                });

                ContactsHelper.DeleteContactAsync(StateService, CurrentContact.Id);
            },
                error =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("contacts.deleteContact error: " + error);
            });
        }
Пример #3
0
        public void DeleteContact()
        {
            if (CurrentContact == null)
            {
                return;
            }

            var messageBoxResult = MessageBox.Show(AppResources.ConfirmDeleteContact, AppResources.Confirm, MessageBoxButton.OKCancel);

            if (messageBoxResult != MessageBoxResult.OK)
            {
                return;
            }

            IsWorking = true;
            MTProtoService.DeleteContactAsync(
                CurrentContact.ToInputUser(),
                result =>
            {
                var link24 = result as TLLink24;
                if (link24 != null)
                {
                    EventAggregator.Publish(new TLUpdateContactLink24 {
                        UserId = link24.User.Id, MyLink = link24.MyLink, ForeignLink = link24.ForeignLink
                    });
                }

                RaiseImportStatusChanged(new ImportEventArgs {
                    Imported = false
                });

                ContactsHelper.DeleteContactAsync(StateService, CurrentContact.Id);

                BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    NotifyOfPropertyChange(() => HasPhone);
                });
            },
                error => BeginOnUIThread(() =>
            {
                IsWorking = false;
                Execute.ShowDebugMessage("contacts.deleteContact error: " + error);
            }));
        }
Пример #4
0
        protected override void OnInitialize()
        {
            if (CurrentContact == null)
            {
                return;
            }

            UpdateNotificationSettings();
            UpdateSubtitles();

            NotifyOfPropertyChange(() => CurrentContact);

            if (CurrentContact == null)
            {
                return;
            }

            Subtitle = DialogDetailsViewModel.GetUserStatus(CurrentContact);

            Execute.BeginOnThreadPool(TimeSpan.FromSeconds(0.5), () =>
            {
                UpdateNotificationSettings();

                IsWorking = true;
                MTProtoService.GetFullUserAsync(
                    CurrentContact.ToInputUser(),
                    userFull =>
                {
                    IsWorking = false;
                    UpdateNotificationSettings();
                    Subtitle = DialogDetailsViewModel.GetUserStatus(CurrentContact);

                    RaiseBlockedStatusChanged(new BlockedEventArgs {
                        Blocked = userFull.Blocked.Value
                    });
                },
                    error =>
                {
                    IsWorking = false;
                    Execute.ShowDebugMessage("users.getFullUser error: " + error);
                });
            });

            base.OnInitialize();
        }