Files
Clario/Clario/Services/SupabaseService.cs
Nouredeen06 d8dea1913a
All checks were successful
Build Linux / build (push) Successful in 1m8s
Added multi-currency support, account/budget management, and settings
- Primary account determines app-wide reference currency; all totals, charts, and summaries convert to it automatically using live rates

- Transactions show both converted and original amounts for cross-currency accounts; IsMultiCurrency recalculates on primary currency change

- Exchange rates fetched live on account save and broadcast via RatesRefreshed so all views update without a restart

- Account create/edit/delete with currency, icon, color, and primary toggle

- Budget create/edit/delete; savings goal dialog

- Settings view: display name, avatar upload, theme, language

- Removed currency selector from Settings (follows primary account)

- Fixed account list sort: primary first, then oldest CreatedAt, per group

- Fixed total balance overlap in dashboard accounts card
2026-04-03 02:39:51 +03:00

44 lines
1.4 KiB
C#

using System;
using System.Text.Json;
using System.Threading.Tasks;
using Supabase;
namespace Clario.Services;
public class SupabaseService
{
private static Client? _client;
public static Client Client => _client ?? throw new InvalidOperationException("Call InitializeAsync First");
public static async Task InitializeAsync(ISessionStorage sessionStorage)
{
_client = new Client(
"https://xzxstbllaivumhtpctmo.supabase.co",
"sb_publishable_cUgUrWvlcGp9Ghnwbfrbnw_ixg_NH7f",
new SupabaseOptions
{
AutoRefreshToken = true,
AutoConnectRealtime = true,
SessionHandler = new SupabaseSessionHandler(sessionStorage)
}
);
await _client.InitializeAsync();
var json = sessionStorage.Load();
if (json is null) return;
var session = JsonSerializer.Deserialize<Supabase.Gotrue.Session>(json);
if (session?.AccessToken is not null && session.RefreshToken is not null)
{
try
{
await _client.Auth.SetSession(session.AccessToken, session.RefreshToken);
}
catch (Exception ex)
{
DebugLogger.Log($"Session restore failed: {ex.Message}");
sessionStorage.Delete(); // session invalid, delete it
}
}
}
}