Offline Patch

This commit is contained in:
Thorbjoern
2025-07-22 21:58:54 +02:00
parent e74f994a8a
commit 1e8853d8c3
3 changed files with 14 additions and 9 deletions
@@ -53,7 +53,9 @@ namespace GhostSystem
private void Start()
{
_offlinePath = Path.Combine(Application.persistentDataPath, "offline_log.jsonl");
string now = DateTime.Now.ToString("yyyyMMdd_HHmmss");
string dateiname = now + ".jsonl";
_offlinePath = Path.Combine(Application.persistentDataPath, dateiname);
}
private void HandleSupabaseReady()
@@ -116,13 +118,15 @@ namespace GhostSystem
private async UniTaskVoid FlushBatchAsync() // Die eigentliche Methode zum Hochladen eines Batches/leeren des Buffers.
{
if (_frameBuffer.Count == 0 || !supabaseReady) return;
if (_frameBuffer.Count == 0) return;
var batch = new List<FrameModel>(_frameBuffer);
_frameBuffer.Clear();
Debug.Log("Flushing Frame Buffer");
try
await FallbackToOfflineAsync(batch);
OnUploadFinished?.Invoke(); // Die Action für das Ende des Ladescreens wird trotzdem ausgelöst.
/*try
{
var response = await SupabaseManager.instance.supabase.From<FrameModel>().Insert(batch); // Versucht, den Batch an Superbase hochzuladen
if (!response.ResponseMessage.IsSuccessStatusCode)
@@ -145,7 +149,7 @@ namespace GhostSystem
await FallbackToOfflineAsync(batch); // Bei nicht erfolgtem Upload wird der Batch lokal gescpeichert.
OnUploadFinished?.Invoke(); // Die Action für das Ende des Ladescreens wird trotzdem ausgelöst.
Debug.Log("Upload Finished");
}
}*/
}
private async UniTask FallbackToOfflineAsync(List<FrameModel> batch) // Schreibt den Buffer in eine Datei, falls Upload nicht möglich
@@ -48,9 +48,9 @@ namespace GhostSystem
}
Debug.Log("🌐 Starting Supabase setup...");
await RunDiagnostics();
//await RunDiagnostics();
await InitSupabaseAsync();
//await InitSupabaseAsync();
OnSuperbaseReady?.Invoke();
}
@@ -141,6 +141,7 @@ namespace GhostSystem
}
else
{
//textbox.text += $"\n\rSupabase health check failed: {www.error}";
Debug.LogError($"❌ Supabase health check failed: {www.error}");
}