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 DeleteAndStop(TLDialogBase dialog) { if (dialog == null) { return; } var user = dialog.With as TLUser; if (user == null || !user.IsBot) { return; } var confirmation = MessageBox.Show(AppResources.DeleteChatConfirmation, AppResources.Confirm, MessageBoxButton.OKCancel); if (confirmation != MessageBoxResult.OK) { return; } IsWorking = true; MTProtoService.BlockAsync(user.ToInputUser(), blocked => { user.Blocked = TLBool.True; CacheService.Commit(); DeleteHistoryAsync(false, user.ToInputPeer(), result => BeginOnUIThread(() => { IsWorking = false; CacheService.DeleteDialog(dialog); // TODO : move this line to MTProtoService if (dialog.With != null) { dialog.With.Bitmap = null; } Items.Remove(dialog); }), error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("messages.deleteHistory error " + error); })); }, error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("contacts.Block error " + error); })); }
protected override void OnActivate() { base.OnActivate(); if (StateService.Participant != null) { var blockedUser = StateService.Participant; StateService.Participant = null; MTProtoService.BlockAsync(blockedUser.ToInputUser(), result => { Items.Add(blockedUser); Status = Items.Count > 0 || LazyItems.Count > 0 ? string.Empty : string.Format("{0}", AppResources.NoUsersHere); }); } }