コード例 #1
0
        private async void CallDeleteExecute(TLCallGroup group)
        {
            var popup = new MessagePopup
            {
                Title               = Strings.Resources.DeleteCalls,
                Message             = Strings.Resources.DeleteSelectedCallsText,
                PrimaryButtonText   = Strings.Resources.Delete,
                SecondaryButtonText = Strings.Resources.Cancel,
                CheckBoxLabel       = Strings.Resources.DeleteCallsForEveryone
            };

            var confirm = await popup.ShowQueuedAsync();

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var response = await ProtoService.SendAsync(new DeleteMessages(group.ChatId, group.Items.Select(x => x.Id).ToArray(), popup.IsChecked == true));

            if (response is Ok)
            {
                Items.Remove(group);
            }
        }
コード例 #2
0
ファイル: CallsViewModel.cs プロジェクト: nazzi88ua/Unigram
        private async void CallDeleteExecute(TLCallGroup group)
        {
            var confirm = await TLMessageDialog.ShowAsync(Strings.Android.ConfirmDeleteCallLog, Strings.Android.AppName, Strings.Android.OK, Strings.Android.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var messages = new TLVector <int>(group.Items.Select(x => x.Id).ToList());

            Task <MTProtoResponse <TLMessagesAffectedMessages> > task;

            var peer = group.Message.Parent.ToInputPeer();

            if (peer is TLInputPeerChannel channelPeer)
            {
                task = ProtoService.DeleteMessagesAsync(new TLInputChannel {
                    ChannelId = channelPeer.ChannelId, AccessHash = channelPeer.AccessHash
                }, messages);
            }
            else
            {
                task = ProtoService.DeleteMessagesAsync(messages, false);
            }

            var response = await task;

            if (response.IsSucceeded)
            {
                var cachedMessages = new TLVector <long>();
                var remoteMessages = new TLVector <int>();
                for (int i = 0; i < messages.Count; i++)
                {
                    if (group.Items[i].RandomId.HasValue && group.Items[i].RandomId != 0L)
                    {
                        cachedMessages.Add(group.Items[i].RandomId.Value);
                    }
                    if (group.Items[i].Id > 0)
                    {
                        remoteMessages.Add(group.Items[i].Id);
                    }
                }

                CacheService.DeleteMessages(peer.ToPeer(), null, remoteMessages);
                CacheService.DeleteMessages(cachedMessages);

                Items.Remove(group);
            }
        }
コード例 #3
0
        private async void CallDeleteExecute(TLCallGroup group)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.ConfirmDeleteCallLog, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm != ContentDialogResult.Primary)
            {
                return;
            }

            var response = await ProtoService.SendAsync(new DeleteMessages(group.ChatId, group.Items.Select(x => x.Id).ToArray(), false));

            if (response is Ok)
            {
                Items.Remove(group);
            }
        }