CommunityToolkit / CommunityToolkit/Graph-Controls

[Feature] GraphPresenter should react to global provider state changes

Aperta
#166 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Area: Controls Controls: GraphPresenter
Lingua principale
C#
Stelle
156
Fork
38
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## 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



...

```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia con il controllo GraphPresenter e la gestione di RequestBuilder, quindi esamina gli eventi provider e provider-state di ProviderManager utilizzati nell’esempio MailMessagesSample. Traccia cosa accade quando il provider cambia o viene effettuato il logout; il lavoro è completato quando il controllo rimane funzionante dopo le modifiche all’accesso e non visualizza contenuti quando l’utente ha effettuato il logout.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
authentication, frontend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.