|
8 | 8 | {
|
9 | 9 | <h2>Welcome @_me.DisplayName!</h2>
|
10 | 10 | <p>
|
11 |
| - You have a grant toal of @_totalPlaylistCount playlists! |
| 11 | + You have a grant total of @_totalPlaylistCount playlists! |
12 | 12 | </p>
|
13 | 13 | }
|
14 | 14 | else
|
|
20 | 20 | }
|
21 | 21 |
|
22 | 22 | @code {
|
23 |
| - private Uri _authUri; |
| 23 | + private Uri _authUri; |
24 | 24 |
|
25 |
| - private bool _isAuthed; |
| 25 | + private bool _isAuthed; |
26 | 26 |
|
27 |
| - private PrivateUser _me; |
| 27 | + private PrivateUser _me; |
28 | 28 |
|
29 |
| - private int _totalPlaylistCount; |
| 29 | + private int _totalPlaylistCount; |
30 | 30 |
|
31 |
| - protected override void OnInitialized() |
32 |
| - { |
33 |
| - var clientId = Environment.GetEnvironmentVariable("SPOTIFY_CLIENT_ID"); |
34 |
| - var baseUri = navManager.ToAbsoluteUri(navManager.BaseUri); |
35 |
| - |
36 |
| - var loginRequest = new LoginRequest(baseUri, clientId, LoginRequest.ResponseType.Token) |
37 |
| - { |
38 |
| - Scope = new[] { Scopes.PlaylistReadPrivate, Scopes.PlaylistReadCollaborative } |
39 |
| - }; |
40 |
| - _authUri = loginRequest.ToUri(); |
41 |
| - } |
| 31 | + protected override void OnInitialized() |
| 32 | + { |
| 33 | + var clientId = Environment.GetEnvironmentVariable("SPOTIFY_CLIENT_ID"); |
| 34 | + var baseUri = navManager.ToAbsoluteUri(navManager.BaseUri); |
42 | 35 |
|
43 |
| - protected override async Task OnInitializedAsync() |
| 36 | + var loginRequest = new LoginRequest(baseUri, clientId, LoginRequest.ResponseType.Token) |
44 | 37 | {
|
45 |
| - var uri = new Uri(navManager.Uri); |
46 |
| - var maxLen = Math.Min(1, uri.Fragment.Length); |
47 |
| - Dictionary<string, string> fragmentParams = uri.Fragment.Substring(maxLen) |
48 |
| - ?.Split("&", StringSplitOptions.RemoveEmptyEntries) |
49 |
| - ?.Select(param => param.Split("=", StringSplitOptions.RemoveEmptyEntries)) |
50 |
| - ?.ToDictionary(param => param[0], param => param[1]) ?? new Dictionary<string, string>(); |
51 |
| - |
52 |
| - _isAuthed = fragmentParams.ContainsKey("access_token"); |
53 |
| - if (_isAuthed) |
54 |
| - { |
55 |
| - var spotify = new SpotifyClient(fragmentParams["access_token"]); |
56 |
| - |
57 |
| - _me = await spotify.UserProfile.Current(); |
58 |
| - _totalPlaylistCount = (await spotify.Playlists.CurrentUsers()).Total; |
59 |
| - } |
| 38 | + Scope = new[] { Scopes.PlaylistReadPrivate, Scopes.PlaylistReadCollaborative } |
| 39 | + }; |
| 40 | + _authUri = loginRequest.ToUri(); |
| 41 | + } |
| 42 | + |
| 43 | + protected override async Task OnInitializedAsync() |
| 44 | + { |
| 45 | + var uri = new Uri(navManager.Uri); |
| 46 | + var maxLen = Math.Min(1, uri.Fragment.Length); |
| 47 | + Dictionary<string, string> fragmentParams = uri.Fragment.Substring(maxLen)? |
| 48 | + .Split("&", StringSplitOptions.RemoveEmptyEntries)? |
| 49 | + .Select(param => param.Split("=", StringSplitOptions.RemoveEmptyEntries))? |
| 50 | + .ToDictionary(param => param[0], param => param[1]) ?? new Dictionary<string, string>(); |
| 51 | + |
| 52 | + _isAuthed = fragmentParams.ContainsKey("access_token"); |
| 53 | + if (_isAuthed) |
| 54 | + { |
| 55 | + var spotify = new SpotifyClient(fragmentParams["access_token"]); |
| 56 | + |
| 57 | + _me = await spotify.UserProfile.Current(); |
| 58 | + _totalPlaylistCount = (await spotify.Playlists.CurrentUsers()).Total; |
60 | 59 | }
|
| 60 | + } |
61 | 61 | }
|
0 commit comments