-
-
Notifications
You must be signed in to change notification settings - Fork 492
/
Copy pathLogOutViewModel.cs
74 lines (66 loc) · 2.32 KB
/
LogOutViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Copyright Fela Ameghino 2015-2025
//
// Distributed under the GNU General Public License v3.0. (See accompanying
// file LICENSE or copy at https://www.gnu.org/licenses/gpl-3.0.txt)
//
using Telegram.Common;
using Telegram.Navigation;
using Telegram.Services;
using Telegram.Td.Api;
using Telegram.Views.Settings;
using Windows.UI.Xaml.Controls;
namespace Telegram.ViewModels
{
public partial class LogOutViewModel : ViewModelBase
{
private readonly IPasscodeService _passcodeService;
public LogOutViewModel(IClientService clientService, ISettingsService settingsService, IEventAggregator aggregator, IPasscodeService passcodeService)
: base(clientService, settingsService, aggregator)
{
_passcodeService = passcodeService;
}
public bool IsPasscodeEnabled => _passcodeService.IsEnabled;
public async void ChangePhoneNumber()
{
await ShowPopupAsync(new ChangePhoneNumberPopup());
}
public async void Ask()
{
var confirm = await ShowPopupAsync(Strings.AskAQuestionInfo, Strings.AskAQuestion, Strings.AskButton, Strings.Cancel);
if (confirm == ContentDialogResult.Primary)
{
var response = await ClientService.SendAsync(new GetSupportUser());
if (response is User user)
{
response = await ClientService.SendAsync(new CreatePrivateChat(user.Id, false));
if (response is Chat chat)
{
NavigationService.NavigateToChat(chat);
}
}
}
}
public async void Logout()
{
var confirm = await ShowPopupAsync(Strings.AreYouSureLogout, Strings.AppName, Strings.OK, Strings.Cancel);
if (confirm != ContentDialogResult.Primary)
{
return;
}
var response = await ClientService.SendAsync(new LogOut());
if (response is Error error)
{
// TODO:
}
}
public void OpenPasscode()
{
NavigationService.NavigateToPasscode();
}
public void OpenStorage()
{
NavigationService.Navigate(typeof(SettingsStoragePage));
}
}
}