Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Gotrue/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class Client : IGotrueClient<User, Session>
/// <remarks></remarks>
/// <example>
/// var client = new Supabase.Gotrue.Client(options);
/// client.LoadSession();
/// await client.LoadSessionAsync();
/// await client.RetrieveSessionAsync();
/// </example>
/// </summary>
Expand Down Expand Up @@ -725,12 +725,19 @@ public async Task RefreshToken()
NotifyAuthStateChange(TokenRefreshed);
}


/// <inheritdoc />
[Obsolete("Call LoadSessionAsync instead.")]
public void LoadSession()
{
if (_sessionPersistence != null) UpdateSession(_sessionPersistence.Persistence.LoadSession());
}

/// <inheritdoc />
public async Task LoadSessionAsync()
{
if (_sessionPersistence != null)
UpdateSession(await _sessionPersistence.Persistence.LoadSessionAsync());
}


/// <inheritdoc />
Expand Down
4 changes: 2 additions & 2 deletions Gotrue/Gotrue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageIconUrl>https://avatars.githubusercontent.com/u/54469796?s=200&amp;v=4</PackageIconUrl>
<PackageProjectUrl>https://github.com/supabase-community/gotrue-csharp</PackageProjectUrl>
<PackageTags>supabase, gotrue</PackageTags>
<PackageVersion>6.0.3</PackageVersion>
<ReleaseVersion>6.0.3</ReleaseVersion>
<PackageVersion>6.0.4</PackageVersion>
<ReleaseVersion>6.0.4</ReleaseVersion>
<RepositoryUrl>https://github.com/supabase-community/gotrue-csharp</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageIcon>icon.png</PackageIcon>
Expand Down
6 changes: 6 additions & 0 deletions Gotrue/Interfaces/IGotrueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,14 @@ public interface IGotrueClient<TUser, TSession> : IGettableHeaders
/// <summary>
/// Loads the session from the persistence layer.
/// </summary>
[Obsolete("Use LoadSessionAsync")]
void LoadSession();

/// <summary>
/// Loads the session asynchronously from the persistence layer.
/// </summary>
Task LoadSessionAsync();

/// <summary>
/// Retrieves the settings from the server
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions Gotrue/Interfaces/IGotrueSessionPersistence.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using System.Threading.Tasks;

namespace Supabase.Gotrue.Interfaces
{
/// <summary>
Expand All @@ -23,6 +26,13 @@ public interface IGotrueSessionPersistence<TSession>
/// Loads the session from the persistence implementation. Returns null if there is no session.
/// </summary>
/// <returns></returns>
[Obsolete("Use LoadSessionAsync instead")]
public TSession? LoadSession();

/// <summary>
/// Loads the session asynchronously from the persistence implementation. Returns null if there is no session.
/// </summary>
/// <returns></returns>
public Task<TSession?> LoadSessionAsync() => Task.FromResult(LoadSession());
}
}
2 changes: 1 addition & 1 deletion GotrueTests/AnonKeyClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task SaveAndLoadUser()
newClient.AddStateChangedListener(AuthStateListener);

// Loads the session from storage
newClient.LoadSession();
await newClient.LoadSessionAsync();

Contains(_stateChanges, SignedIn);
AreEqual(newClient.CurrentSession, newPersistence.SavedSession);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async void Initialize() {
client.AddStateChangedListener(AuthStateListener);

// Load the session from persistence
client.LoadSession();
await client.LoadSessionAsync();
// Loads the session using SessionRetriever and sets state internally.
await client.RetrieveSessionAsync();
}
Expand Down