1
1
using System ;
2
+ using System . IO ;
2
3
using Microsoft . UI . Xaml . Controls ;
3
4
using TdLib ;
4
5
using System . Threading . Tasks ;
@@ -17,7 +18,6 @@ public sealed partial class AccountView : Page
17
18
private string _username ;
18
19
private string _bio ;
19
20
private string _phoneNumber ;
20
- private TdApi . ProfilePhoto _profilePicture ;
21
21
22
22
public AccountView ( )
23
23
{
@@ -29,19 +29,20 @@ public AccountView()
29
29
private async void InitializeAllVariables ( )
30
30
{
31
31
var currentUser = await GetCurrentUser ( ) ;
32
+ var userFullInfo = await _client . GetUserFullInfoAsync ( currentUser . Id ) ;
32
33
GetProfilePhoto ( currentUser ) ;
33
34
34
35
_firstName = $ "{ currentUser . FirstName } ";
35
36
_lastName = $ "{ currentUser . LastName } ";
36
37
_username = $ "@{ currentUser . Usernames ? . ActiveUsernames [ 0 ] } ";
37
- // _bio = $"{}"
38
+ _bio = $ "{ userFullInfo . Bio . Text } " ;
38
39
_phoneNumber = $ "+{ currentUser . PhoneNumber } ";
39
40
40
- textBlock_Username . Text = _username ;
41
- textBlock_FirstName . Text = _firstName ;
42
- textBlock_LastName . Text = _lastName ;
43
- textBlock_Bio . Text = "я не ебу как достать био, чес слово" ;
44
- textBlock_PhoneNumber . Content = _phoneNumber ;
41
+ TextBoxUsername . Text = _username ;
42
+ TextBoxFirstName . Text = _firstName ;
43
+ TextBoxLastName . Text = _lastName ;
44
+ TextBoxBio . Text = _bio ;
45
+ TextBoxPhoneNumber . Content = _phoneNumber ;
45
46
}
46
47
47
48
private async void GetProfilePhoto ( TdApi . User user )
@@ -53,8 +54,10 @@ private async void GetProfilePhoto(TdApi.User user)
53
54
FileId = user . ProfilePhoto . Big . Id ,
54
55
Priority = 1
55
56
} ) ;
56
-
57
- image_ProfilePicture . ImageSource = new BitmapImage ( new Uri ( profilePhoto . Local . Path ) ) ;
57
+
58
+ if ( ! Directory . Exists ( profilePhoto . Local . Path ) ) return ;
59
+
60
+ ImageProfilePicture . ImageSource = new BitmapImage ( new Uri ( profilePhoto . Local . Path ) ) ;
58
61
}
59
62
catch ( Exception e )
60
63
{
@@ -73,37 +76,37 @@ private async void Button_LogOut_OnClick(object sender, RoutedEventArgs e)
73
76
await _client . ExecuteAsync ( new TdApi . LogOut ( ) ) ;
74
77
}
75
78
76
- private void TextBlock_PhoneNumber_OnClick ( object sender , RoutedEventArgs e )
77
- {
78
- throw new NotImplementedException ( ) ;
79
- }
80
-
81
79
private void Button_Apply_OnClick ( object sender , RoutedEventArgs e )
82
80
{
83
- //_client.ExecuteAsync(new TdApi.SetProfilePhoto
84
- //{
85
- // Photo = _profilePicture
86
- //});
87
-
88
- _client . ExecuteAsync ( new TdApi . SetName
81
+ if ( TextBoxUsername . Text != _username )
89
82
{
90
- FirstName = _firstName ,
91
- LastName = _lastName
92
- } ) ;
83
+ _username = TextBoxUsername . Text ;
84
+
85
+ _client . ExecuteAsync ( new TdApi . SetUsername
86
+ {
87
+ Username = _username
88
+ } ) ;
89
+ }
93
90
94
- //if (_bio != GetCurrentUser().Result.Extra.)
95
- //{
96
- // _client.ExecuteAsync(new TdApi.SetBio
97
- // {
98
- // Bio = _bio
99
- // });
100
- //}
91
+ if ( TextBoxFirstName . Text != _firstName || TextBoxLastName . Text != _lastName )
92
+ {
93
+ _firstName = TextBoxFirstName . Text ;
94
+ _lastName = TextBoxLastName . Text ;
95
+
96
+ _client . ExecuteAsync ( new TdApi . SetName
97
+ {
98
+ FirstName = _firstName ,
99
+ LastName = _lastName
100
+ } ) ;
101
+ }
101
102
102
- if ( _username != GetCurrentUser ( ) . Result . Usernames . ActiveUsernames [ 0 ] )
103
+ if ( TextBoxBio . Text != _bio )
103
104
{
104
- _client . ExecuteAsync ( new TdApi . SetUsername
105
+ _bio = TextBoxBio . Text ;
106
+
107
+ _client . ExecuteAsync ( new TdApi . SetBio
105
108
{
106
- Username = _username
109
+ Bio = _bio
107
110
} ) ;
108
111
}
109
112
}
0 commit comments