Ejemplo n.º 1
0
        private async void ThemeDeleteExecute(ThemeCustomInfo theme)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.DeleteThemeAlert, Strings.Resources.AppName, Strings.Resources.Delete, Strings.Resources.Cancel);

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

            try
            {
                var file = await StorageFile.GetFileFromPathAsync(theme.Path);

                await file.DeleteAsync();
            }
            catch { }

            if (Settings.Appearance[Settings.Appearance.RequestedTheme].Custom == theme.Path)
            {
                await SetThemeAsync(new ThemeBundledInfo { Parent = theme.Parent });
            }
            else
            {
                await RefreshThemesAsync();
            }
        }
Ejemplo n.º 2
0
        protected override async void DeleteExecute()
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureDeletePhoto, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary && _selectedItem is GalleryChatPhoto chatPhoto)
            {
                Function function;
                if (chatPhoto.MessageId == 0)
                {
                    function = new SetChatPhoto(_chat.Id, null);
                }
                else
                {
                    function = new DeleteMessages(_chat.Id, new[] { chatPhoto.MessageId }, true);
                }

                var response = await ProtoService.SendAsync(function);

                if (response is Ok)
                {
                    var index = Items.IndexOf(chatPhoto);
                    if (index < Items.Count - 1 && chatPhoto.MessageId != 0)
                    {
                        SelectedItem = Items[index > 0 ? index - 1 : index + 1];
                        Items.Remove(chatPhoto);
                        TotalItems--;
                    }
                    else
                    {
                        NavigationService.GoBack();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private async void AddExecute()
        {
            var chat = _chat;

            if (chat == null)
            {
                return;
            }

            var selected = await SharePopup.PickChatAsync(Strings.Resources.SelectContact);

            var user = CacheService.GetUser(selected);

            if (user == null)
            {
                return;
            }

            var confirm = await MessagePopup.ShowAsync(string.Format(Strings.Resources.AddToTheGroup, user.GetFullName()), Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

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

            var response = await ProtoService.SendAsync(new AddChatMember(chat.Id, user.Id, CacheService.Options.ForwardedMessageCountMax));

            if (response is Error error)
            {
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> VerifyRightsAsync(Chat chat, Func <ChatPermissions, bool> permission, string global, string forever, string temporary)
        {
            if (chat.Type is ChatTypeSupergroup super)
            {
                var supergroup = ProtoService.GetSupergroup(super.SupergroupId);
                if (supergroup == null)
                {
                    return(false);
                }

                if (supergroup.Status is ChatMemberStatusRestricted restricted && !permission(restricted.Permissions))
                {
                    if (restricted.IsForever())
                    {
                        await MessagePopup.ShowAsync(forever, Strings.Resources.AppName, Strings.Resources.OK);
                    }
                    else
                    {
                        await MessagePopup.ShowAsync(string.Format(temporary, BindConvert.Current.BannedUntil(restricted.RestrictedUntilDate)), Strings.Resources.AppName, Strings.Resources.OK);
                    }

                    return(true);
                }
                else if (supergroup.Status is ChatMemberStatusMember)
                {
                    if (!permission(chat.Permissions))
                    {
                        await MessagePopup.ShowAsync(global, Strings.Resources.AppName, Strings.Resources.OK);

                        return(true);
                    }
                }
            }
Ejemplo n.º 5
0
        public async Task <bool> CheckDeviceAccessAsync()
        {
            var access = DeviceAccessInformation.CreateFromDeviceClass(DeviceClass.Location);

            if (access.CurrentStatus == DeviceAccessStatus.Unspecified)
            {
                var accessStatus = await Geolocator.RequestAccessAsync();

                if (accessStatus == GeolocationAccessStatus.Allowed)
                {
                    return(true);
                }

                return(false);
            }
            else if (access.CurrentStatus != DeviceAccessStatus.Allowed)
            {
                var message = Strings.Resources.PermissionNoLocationPosition;

                var confirm = await MessagePopup.ShowAsync(message, Strings.Resources.AppName, Strings.Resources.PermissionOpenSettings, Strings.Resources.OK);

                if (confirm == ContentDialogResult.Primary)
                {
                    await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
                }

                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        private async void DisableExecute()
        {
            var state = _passwordState;

            if (state == null)
            {
                return;
            }

            var message = Strings.Resources.TurnPasswordOffQuestion;

            if (state.HasPassportData)
            {
                message += Environment.NewLine + Environment.NewLine + Strings.Resources.TurnPasswordOffPassport;
            }

            var confirm = await MessagePopup.ShowAsync(message, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

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

            var response = await ProtoService.SendAsync(new SetPassword(_password, string.Empty, string.Empty, false, string.Empty));

            if (response is PasswordState passwordState)
            {
                Update(passwordState, false);
            }
            else
            {
            }
        }
Ejemplo n.º 7
0
        private async void ChatsClearExecute()
        {
            var chats = SelectedItems.ToList();

            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureClearHistoryFewChats, Locale.Declension("ChatsSelected", chats.Count), Strings.Resources.ClearHistory, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                Delegate?.ShowChatsUndo(chats, UndoType.Clear, items =>
                {
                    foreach (var undo in items)
                    {
                        _deletedChats.Remove(undo.Id);
                        Items.Handle(undo.Id, undo.Positions);
                    }
                }, items =>
                {
                    var clear = items.FirstOrDefault();
                    if (clear == null)
                    {
                        return;
                    }

                    ProtoService.Send(new DeleteChatHistory(clear.Id, false, false));
                });
            }

            Delegate?.SetSelectionMode(false);
            SelectedItems.Clear();
        }
Ejemplo n.º 8
0
        private async void UpdateLocationExecute()
        {
            var location = await _locationService.GetPositionAsync();

            if (location == null)
            {
                var confirm = await MessagePopup.ShowAsync(Strings.Resources.GpsDisabledAlert, Strings.Resources.AppName, Strings.Resources.ConnectingToProxyEnable, Strings.Resources.Cancel);

                if (confirm == ContentDialogResult.Primary)
                {
                    await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
                }

                return;
            }

            var geopoint = new Geopoint(new BasicGeoposition {
                Latitude = location.Latitude, Longitude = location.Longitude
            });

            Location = location;
            Settings.Appearance.UpdateNightMode();

            var result = await MapLocationFinder.FindLocationsAtAsync(geopoint, MapLocationDesiredAccuracy.Low);

            if (result.Status == MapLocationFinderStatus.Success)
            {
                Town = result.Locations[0].Address.Town;
            }
        }
        private async void ForgotExecute()
        {
            if (_parameters == null)
            {
                // TODO: ...
                return;
            }

            if (_parameters.HasRecoveryEmailAddress)
            {
                IsLoading = true;

                var response = await ProtoService.SendAsync(new RequestAuthenticationPasswordRecovery());

                if (response is Error error)
                {
                    IsLoading = false;
                    await MessagePopup.ShowAsync(error.Message, Strings.Resources.AppName, Strings.Resources.OK);
                }
            }
            else
            {
                await MessagePopup.ShowAsync(Strings.Resources.RestorePasswordNoEmailText, Strings.Resources.RestorePasswordNoEmailTitle, Strings.Resources.OK);

                IsResettable = true;
            }
        }
Ejemplo n.º 10
0
        private async void SendExecute()
        {
            var response = await ProtoService.SendAsync(new ImportContacts(new[] { new Contact(_phoneCode + _phoneNumber, _firstName, _lastName, string.Empty, 0) }));

            if (response is ImportedContacts imported)
            {
                if (imported.UserIds.Count > 0)
                {
                    var create = await ProtoService.SendAsync(new CreatePrivateChat(imported.UserIds[0], false));

                    if (create is Chat chat)
                    {
                        NavigationService.NavigateToChat(chat);
                    }
                    else
                    {
                        await MessagePopup.ShowAsync(Strings.Resources.ContactNotRegistered, Strings.Resources.AppName, Strings.Resources.Invite, Strings.Resources.Cancel);
                    }
                }
                else
                {
                    await MessagePopup.ShowAsync(Strings.Resources.ContactNotRegistered, Strings.Resources.AppName, Strings.Resources.Invite, Strings.Resources.Cancel);
                }
            }
            else
            {
                await MessagePopup.ShowAsync(Strings.Resources.ContactNotRegistered, Strings.Resources.AppName, Strings.Resources.Invite, Strings.Resources.Cancel);
            }
        }
Ejemplo n.º 11
0
        public void Handle(UpdateServiceNotification update)
        {
            var caption = update.Content.GetCaption();

            if (caption == null)
            {
                return;
            }

            var text = caption.Text;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            BeginOnUIThread(async() =>
            {
                if (update.Type.StartsWith("AUTH_KEY_DROP_"))
                {
                    var confirm = await MessagePopup.ShowAsync(text, Strings.Resources.AppName, Strings.Resources.LogOut, Strings.Resources.Cancel);
                    if (confirm == ContentDialogResult.Primary)
                    {
                        _protoService.Send(new Destroy());
                    }
                }
                else
                {
                    await MessagePopup.ShowAsync(text, Strings.Resources.AppName, Strings.Resources.OK);
                }
            });
        }
Ejemplo n.º 12
0
        private async void Initialize()
        {
            if (!Settings.IsContactsSyncRequested)
            {
                Settings.IsContactsSyncRequested = true;

                var confirm = await MessagePopup.ShowAsync(Strings.Resources.ContactsPermissionAlert, Strings.Resources.AppName, Strings.Resources.ContactsPermissionAlertContinue, Strings.Resources.ContactsPermissionAlertNotNow);

                if (confirm != Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
                {
                    Settings.IsContactsSyncEnabled = false;
                    await _contactsService.RemoveAsync();
                }

                if (Settings.IsContactsSyncEnabled)
                {
                    ProtoService.Send(new GetContacts(), async result =>
                    {
                        if (result is Telegram.Td.Api.Users users)
                        {
                            await _contactsService.SyncAsync(users);
                        }
                    });
                }
            }
        }
Ejemplo n.º 13
0
        public async void Handle(UpdateTermsOfService update)
        {
            var terms = update.TermsOfService;

            if (terms == null)
            {
                return;
            }

            async void DeleteAccount()
            {
                var decline = await MessagePopup.ShowAsync(Strings.Resources.TosUpdateDecline, Strings.Resources.TermsOfService, Strings.Resources.DeclineDeactivate, Strings.Resources.Back);

                if (decline != ContentDialogResult.Primary)
                {
                    Handle(update);
                    return;
                }

                var delete = await MessagePopup.ShowAsync(Strings.Resources.TosDeclineDeleteAccount, Strings.Resources.AppName, Strings.Resources.Deactivate, Strings.Resources.Cancel);

                if (delete != ContentDialogResult.Primary)
                {
                    Handle(update);
                    return;
                }

                _protoService.Send(new DeleteAccount("Decline ToS update"));
            }

            if (terms.ShowPopup)
            {
                await Task.Delay(2000);

                BeginOnUIThread(async() =>
                {
                    var confirm = await MessagePopup.ShowAsync(terms.Text, Strings.Resources.PrivacyPolicyAndTerms, Strings.Resources.Agree, Strings.Resources.Cancel);
                    if (confirm != ContentDialogResult.Primary)
                    {
                        DeleteAccount();
                        return;
                    }

                    if (terms.MinUserAge > 0)
                    {
                        var age = await MessagePopup.ShowAsync(string.Format(Strings.Resources.TosAgeText, terms.MinUserAge), Strings.Resources.TosAgeTitle, Strings.Resources.Agree, Strings.Resources.Cancel);
                        if (age != ContentDialogResult.Primary)
                        {
                            DeleteAccount();
                            return;
                        }
                    }

                    _protoService.Send(new AcceptTermsOfService(update.TermsOfServiceId));
                });
            }
        }
        private async void UnblockExecute(User user)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureUnblockContact, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                ProtoService.Send(new UnblockUser(user.Id));
            }
        }
Ejemplo n.º 15
0
        private async void CopyExecute()
        {
            var dataPackage = new DataPackage();

            dataPackage.SetText(_inviteLink);
            ClipboardEx.TrySetContent(dataPackage);

            await MessagePopup.ShowAsync(Strings.Resources.LinkCopied, Strings.Resources.AppName, Strings.Resources.OK);
        }
Ejemplo n.º 16
0
        private async Task <bool> CheckDeviceAccessAsync(bool audio, ChatRecordMode mode)
        {
            // For some reason, as far as I understood, CurrentStatus is always Unspecified on Xbox
            if (string.Equals(AnalyticsInfo.VersionInfo.DeviceFamily, "Windows.Xbox"))
            {
                return(true);
            }

            var access = DeviceAccessInformation.CreateFromDeviceClass(audio ? DeviceClass.AudioCapture : DeviceClass.VideoCapture);

            if (access.CurrentStatus == DeviceAccessStatus.Unspecified)
            {
                MediaCapture capture = null;
                try
                {
                    capture = new MediaCapture();
                    var settings = new MediaCaptureInitializationSettings();
                    settings.StreamingCaptureMode = mode == ChatRecordMode.Video
                        ? StreamingCaptureMode.AudioAndVideo
                        : StreamingCaptureMode.Audio;
                    await capture.InitializeAsync(settings);
                }
                catch { }
                finally
                {
                    if (capture != null)
                    {
                        capture.Dispose();
                        capture = null;
                    }
                }

                return(false);
            }
            else if (access.CurrentStatus != DeviceAccessStatus.Allowed)
            {
                var message = audio
                    ? mode == ChatRecordMode.Voice
                    ? Strings.Resources.PermissionNoAudio
                    : Strings.Resources.PermissionNoAudioVideo
                    : Strings.Resources.PermissionNoCamera;

                this.BeginOnUIThread(async() =>
                {
                    var confirm = await MessagePopup.ShowAsync(message, Strings.Resources.AppName, Strings.Resources.PermissionOpenSettings, Strings.Resources.OK);
                    if (confirm == ContentDialogResult.Primary)
                    {
                        await Launcher.LaunchUriAsync(new Uri("ms-settings:appsfeatures-app"));
                    }
                });

                return(false);
            }

            return(true);
        }
Ejemplo n.º 17
0
        private async void UnblockExecute(MessageSender sender)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureUnblockContact, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                Items.Remove(sender);
                ProtoService.Send(new ToggleMessageSenderIsBlocked(sender, false));
            }
        }
        private async void Change_Click(object sender, RoutedEventArgs e)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.PhoneNumberAlert, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                Frame.Navigate(typeof(SettingsPhonePage));
                Frame.BackStack.Remove(Frame.BackStack.Last());
            }
        }
Ejemplo n.º 19
0
        private async void ThemeCreateExecute(ThemeInfoBase theme)
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.CreateNewThemeAlert, Strings.Resources.NewTheme, Strings.Resources.CreateTheme, Strings.Resources.Cancel);

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

            var input = new InputDialog();

            input.Title  = Strings.Resources.NewTheme;
            input.Header = Strings.Resources.EnterThemeName;
            input.Text   = $"{theme.Name} #2";
            input.IsPrimaryButtonEnabled   = true;
            input.IsSecondaryButtonEnabled = true;
            input.PrimaryButtonText        = Strings.Resources.OK;
            input.SecondaryButtonText      = Strings.Resources.Cancel;

            confirm = await input.ShowQueuedAsync();

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

            var preparing = new ThemeCustomInfo {
                Name = input.Text, Parent = theme.Parent
            };
            var fileName = Client.Execute(new CleanFileName(theme.Name)) as Text;

            if (theme is ThemeCustomInfo custom)
            {
                foreach (var item in custom.Values)
                {
                    preparing.Values[item.Key] = item.Value;
                }
            }
            else if (theme is ThemeAccentInfo accent)
            {
                foreach (var item in accent.Values)
                {
                    preparing.Values[item.Key] = item.Value;
                }
            }

            var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("themes\\" + fileName.TextValue + ".unigram-theme", CreationCollisionOption.GenerateUniqueName);

            await _themeService.SerializeAsync(file, preparing);

            preparing.Path = file.Path;

            ThemeEditExecute(preparing);
        }
        private async void CopyLinkExecute(ProxyViewModel proxy)
        {
            var response = await ProtoService.SendAsync(new GetProxyLink(proxy.Id));

            if (response is Text text && Uri.TryCreate(text.TextValue, UriKind.Absolute, out Uri uri))
            {
                var dataPackage = new Windows.ApplicationModel.DataTransfer.DataPackage();
                dataPackage.SetText(text.TextValue);
                ClipboardEx.TrySetContent(dataPackage);
                await MessagePopup.ShowAsync(Strings.Resources.LinkCopied, Strings.Resources.UseProxyTelegram, Strings.Resources.OK);
            }
        }
Ejemplo n.º 21
0
            private async void SendExecute()
            {
                var oldPassword    = _viewModel.Password ?? string.Empty;
                var password       = _password ?? string.Empty;
                var passwordRetype = _passwordRetype ?? string.Empty;
                var passwordHint   = _passwordHint ?? string.Empty;
                var emailAddress   = _emailAddress ?? string.Empty;
                var emailValid     = true;

                if (string.IsNullOrWhiteSpace(password))
                {
                    // Error
                    return;
                }

                if (!string.Equals(password, passwordRetype))
                {
                    // Error
                    await MessagePopup.ShowAsync(Strings.Resources.PasswordDoNotMatch, Strings.Resources.AppName, Strings.Resources.OK);

                    return;
                }

                if (string.IsNullOrEmpty(emailAddress) || !new EmailAddressAttribute().IsValid(emailAddress))
                {
                    emailValid   = false;
                    emailAddress = string.Empty;

                    var confirm = await MessagePopup.ShowAsync(Strings.Resources.YourEmailSkipWarningText, Strings.Resources.YourEmailSkipWarning, Strings.Resources.YourEmailSkip, Strings.Resources.Cancel);

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

                var response = await ProtoService.SendAsync(new SetPassword(oldPassword, password, passwordHint, emailValid, emailAddress));

                if (response is PasswordState passwordState)
                {
                    _viewModel.Update(passwordState, true);
                }
                else if (response is Error error)
                {
                    if (error.TypeEquals(ErrorType.EMAIL_UNCONFIRMED))
                    {
                    }
                }
            }
Ejemplo n.º 22
0
        private async void UnlinkExecute()
        {
            var chat = _chat;

            if (chat == null)
            {
                return;
            }

            var supergroup = CacheService.GetSupergroup(chat);

            if (supergroup == null)
            {
                return;
            }

            var fullInfo = CacheService.GetSupergroupFull(chat);

            if (fullInfo == null)
            {
                return;
            }

            var linkedChat = CacheService.GetChat(fullInfo.LinkedChatId);

            if (linkedChat == null)
            {
                return;
            }

            var confirm = await MessagePopup.ShowAsync(string.Format(Strings.Resources.DiscussionUnlinkChannelAlert, linkedChat.Title), Strings.Resources.DiscussionUnlinkGroup, Strings.Resources.DiscussionUnlink, Strings.Resources.Cancel);

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

            var response = await ProtoService.SendAsync(new SetChatDiscussionGroup(supergroup.IsChannel ? chat.Id : linkedChat.Id, 0));

            if (response is Ok && !supergroup.IsChannel)
            {
                NavigationService.GoBack();
                NavigationService.Frame.ForwardStack.Clear();
            }
            else
            {
            }
        }
Ejemplo n.º 23
0
        private async void ClearDraftsExecute()
        {
            var confirm = await MessagePopup.ShowAsync(Strings.Resources.AreYouSureClearDrafts, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

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

            var clear = await ProtoService.SendAsync(new ClearAllDraftMessages(true));

            if (clear is Error)
            {
                // TODO
            }
        }
Ejemplo n.º 24
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);
            }
        }
Ejemplo n.º 25
0
        private async void VoiceMessages_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel.ProtoService.IsPremium)
            {
                Frame.Navigate(typeof(SettingsPrivacyAllowPrivateVoiceAndVideoNoteMessagesPage));
            }
            else if (ViewModel.ProtoService.IsPremiumAvailable)
            {
                var confirm = await MessagePopup.ShowAsync(Strings.Resources.PrivacyVoiceMessagesPremiumOnly, Strings.Resources.PrivacyVoiceMessages, Strings.Resources.OK, Strings.Resources.Cancel);

                if (confirm == ContentDialogResult.Primary)
                {
                    ViewModel.NavigationService.ShowPromo(/*new PremiumSourceFeature(new PremiumFeaturePrivateVoiceAndVideoMessages)*/);
                }
            }
        }
Ejemplo n.º 26
0
        private async void CopyExecute()
        {
            var link = ShareLink;

            if (link == null)
            {
                return;
            }

            var dataPackage = new DataPackage();

            dataPackage.SetText(link.AbsoluteUri);
            ClipboardEx.TrySetContent(dataPackage);

            await MessagePopup.ShowAsync(Strings.Resources.LinkCopied, Strings.Resources.AppName, Strings.Resources.OK);
        }
Ejemplo n.º 27
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 messages = new TLVector<int>(group.Items.Select(x => x.Id).ToList());

            //Task<MTProtoResponse<TLMessagesAffectedMessages>> task = null;

            //var peer = group.Message.Parent.ToInputPeer();
            //if (peer is TLInputPeerChannel channelPeer)
            //{
            //    task = LegacyService.DeleteMessagesAsync(new TLInputChannel { ChannelId = channelPeer.ChannelId, AccessHash = channelPeer.AccessHash }, messages);
            //}
            //else
            //{
            //    task = LegacyService.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);
            //}
        }
Ejemplo n.º 28
0
        private async void TopChatDeleteExecute(Chat chat)
        {
            if (chat == null)
            {
                return;
            }

            var confirm = await MessagePopup.ShowAsync(string.Format(Strings.Resources.ChatHintsDelete, CacheService.GetTitle(chat)), Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

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

            ProtoService.Send(new RemoveTopChat(new TopChatCategoryUsers(), chat.Id));
            TopChats?.Remove(chat);
        }
Ejemplo n.º 29
0
        private async void ChangePhoneNumber_Click(object sender, RoutedEventArgs e)
        {
            var popup  = new ChangePhoneNumberPopup();
            var change = await popup.ShowQueuedAsync();

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

            var confirm = await MessagePopup.ShowAsync(Strings.Resources.PhoneNumberAlert, Strings.Resources.AppName, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm == ContentDialogResult.Primary)
            {
                Frame.Navigate(typeof(SettingsPhonePage));
            }
        }
Ejemplo n.º 30
0
        public async void Handle(UpdateSuggestedActions update)
        {
            foreach (var action in update.AddedActions)
            {
                if (action is SuggestedActionEnableArchiveAndMuteNewChats)
                {
                    var confirm = await MessagePopup.ShowAsync(Strings.Resources.HideNewChatsAlertText, Strings.Resources.HideNewChatsAlertTitle, Strings.Resources.OK, Strings.Resources.Cancel);

                    if (confirm == ContentDialogResult.Primary)
                    {
                        _protoService.Options.ArchiveAndMuteNewChatsFromUnknownUsers = true;
                    }

                    _protoService.Send(new HideSuggestedAction(action));
                }
            }
        }