CommunityToolkit / CommunityToolkit/Graph-Controls

[Feature] GraphPresenter should react to global provider state changes

Đang mở
#166 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Area: Controls Controls: GraphPresenter
Ngôn ngữ chính
C#
Star
156
Fork
38
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Describe the problem this feature would solve

The `GraphPresenter` requires an `IBaseRequestBuilder` implementation to determine what data to fetch from Graph. We don't currently have a good way to define the `RequestBuilder` property in XAML, so this must be done from code. The problem is that if the provider state changes after the `RequestBuilder` property is set, the `GraphPresenter` will fail. The way to fix this is to nullify the `RequestBuilder`, and then re-set it.

## Describe the solution

Update the `GraphPresenter` to listen for changes in the global provider state, and do whatever is required to keep the control functional after a login change.

The `GraphPresenter` should not display any content if the global provider is not signed in.

## Describe alternatives you've considered

None

## Additional context & Screenshots

All of this code is required to support a single instance of the `GraphPresenter` control:

```csharp
namespace SampleTest.Samples.GraphPresenter
{
public sealed partial class MailMessagesSample : Page
{
public IBaseRequestBuilder MessagesRequestBuilder { get; set; }

public MailMessagesSample()
{
this.InitializeComponent();
ProviderManager.Instance.ProviderUpdated += OnProviderUpdated;
ProviderManager.Instance.ProviderStateChanged += OnProviderStateChanged;
}

private void OnProviderUpdated(object sender, IProvider provider)
{
if (provider == null)
{
ClearRequestBuilders();
}
}

private void OnProviderStateChanged(object sender, ProviderStateChangedEventArgs e)
{
if (e.NewState == ProviderState.SignedIn)
{
var graphClient = ProviderManager.Instance.GlobalProvider.GetClient();

MessagesRequestBuilder = graphClient.Me.Messages;
}
else
{
ClearRequestBuilders();
}
}

private void ClearRequestBuilders()
{
MessagesRequestBuilder = null;
}
}
}
```

```xml



...

```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.