Skip to content

Commit 6c89168

Browse files
authored
Merge branch 'master' into hideFlyoutOnClick
2 parents d25988e + 8b8bed2 commit 6c89168

File tree

5 files changed

+70
-17
lines changed

5 files changed

+70
-17
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: Create a report to help us fix something that isn't working as expected
44
title: ''
5-
labels: bug
5+
labels: "bug :bug:"
66
assignees: ''
77

88
---

.github/ISSUE_TEMPLATE/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Documentation
33
about: I have a documentation suggestion or question
44
title: "[Docs]"
5-
labels: documentation
5+
labels: "documentation :page_with_curl:"
66
assignees: ''
77

88
---

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Fixes #
2+
<!-- Link to relevant issue (for ex: #1234) which will automatically close the issue once the PR is merged -->
3+
4+
## PR Type
5+
What kind of change does this PR introduce?
6+
<!-- Please uncomment one ore more that apply to this PR -->
7+
8+
<!-- - Bugfix -->
9+
<!-- - Feature -->
10+
<!-- - Code style update (formatting) -->
11+
<!-- - Refactoring (no functional changes, no api changes) -->
12+
<!-- - Build or CI related changes -->
13+
<!-- - Documentation content changes -->
14+
<!-- - Sample app changes -->
15+
<!-- - Other... Please describe: -->
16+
17+
18+
## What is the current behavior?
19+
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
20+
21+
22+
## What is the new behavior?
23+
24+
25+
## PR Checklist
26+
27+
Please check if your PR fulfills the following requirements:
28+
29+
- [ ] Tested code with current [supported SDKs](https://github.com/windows-toolkit/Graph-Controls/blob/master/README.md)
30+
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
31+
- [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)
32+
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
33+
- [ ] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
34+
- [ ] Contains **NO** breaking changes
35+
36+
37+
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
38+
Please note that breaking changes are likely to be rejected -->
39+
40+
41+
## Other information

Microsoft.Toolkit.Graph.Controls/Controls/LoginButton/LoginButton.Properties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ public bool IsLoading
4646
/// The identifier for the <see cref="IsLoading"/> dependency property.
4747
/// </returns>
4848
public static readonly DependencyProperty IsLoadingProperty =
49-
DependencyProperty.Register("IsLoading", typeof(bool), typeof(LoginButton), new PropertyMetadata(true));
49+
DependencyProperty.Register(nameof(IsLoading), typeof(bool), typeof(LoginButton), new PropertyMetadata(true));
5050
}
5151
}

Microsoft.Toolkit.Graph.Controls/Controls/LoginButton/LoginButton.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.ComponentModel;
7+
using System.Diagnostics;
78
using System.Threading.Tasks;
89
using Microsoft.Toolkit.Graph.Providers;
910
using Windows.UI.Xaml;
@@ -32,22 +33,15 @@ public LoginButton()
3233
{
3334
this.DefaultStyleKey = typeof(LoginButton);
3435

35-
ProviderManager.Instance.ProviderUpdated += (sender, args) =>
36-
{
37-
if (!IsLoading && ProviderManager.Instance?.GlobalProvider?.State == ProviderState.Loading)
38-
{
39-
IsLoading = true;
40-
}
41-
42-
LoadData();
43-
};
36+
ProviderManager.Instance.ProviderUpdated += (sender, args) => LoadData();
4437
}
4538

4639
/// <inheritdoc/>
4740
protected override void OnApplyTemplate()
4841
{
4942
base.OnApplyTemplate();
5043

44+
IsLoading = true;
5145
LoadData();
5246

5347
if (_loginButton != null)
@@ -110,7 +104,11 @@ private async void LoadData()
110104
return;
111105
}
112106

113-
if (provider.State == ProviderState.SignedIn)
107+
if (provider.State == ProviderState.Loading)
108+
{
109+
IsLoading = true;
110+
}
111+
else if (provider.State == ProviderState.SignedIn)
114112
{
115113
try
116114
{
@@ -122,18 +120,20 @@ private async void LoadData()
122120
{
123121
LoginFailed?.Invoke(this, new LoginFailedEventArgs(e));
124122
}
123+
124+
IsLoading = false;
125125
}
126126
else if (provider.State == ProviderState.SignedOut)
127127
{
128128
UserDetails = null; // What if this was user provided? Should we not hook into these events then?
129+
130+
IsLoading = false;
129131
}
130132
else
131133
{
132134
// Provider in Loading state
133-
return;
135+
Debug.Fail("unsupported state");
134136
}
135-
136-
IsLoading = false;
137137
}
138138

139139
/// <summary>
@@ -142,7 +142,7 @@ private async void LoadData()
142142
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
143143
public async Task LoginAsync()
144144
{
145-
if (UserDetails != null)
145+
if (UserDetails != null || IsLoading)
146146
{
147147
return;
148148
}
@@ -153,6 +153,7 @@ public async Task LoginAsync()
153153
{
154154
try
155155
{
156+
IsLoading = true;
156157
await provider.LoginAsync();
157158

158159
if (provider.State == ProviderState.SignedIn)
@@ -171,6 +172,10 @@ public async Task LoginAsync()
171172
{
172173
LoginFailed?.Invoke(this, new LoginFailedEventArgs(e));
173174
}
175+
finally
176+
{
177+
IsLoading = false;
178+
}
174179
}
175180
}
176181

@@ -186,6 +191,11 @@ public async Task LogoutAsync()
186191
flyout.Hide();
187192
}
188193

194+
if (IsLoading)
195+
{
196+
return;
197+
}
198+
189199
var cargs = new CancelEventArgs();
190200
LogoutInitiated?.Invoke(this, cargs);
191201

@@ -207,7 +217,9 @@ public async Task LogoutAsync()
207217

208218
if (provider != null)
209219
{
220+
IsLoading = true;
210221
await provider.LogoutAsync();
222+
IsLoading = false;
211223

212224
LogoutCompleted?.Invoke(this, new EventArgs());
213225
}

0 commit comments

Comments
 (0)