Retrieve SyncableTables info from Rust Core (#1404)

This commit is contained in:
Leendert de Borst
2025-12-26 23:24:18 +01:00
parent 24efd92fe8
commit 96e68b2bce
2 changed files with 9 additions and 41 deletions

View File

@@ -131,22 +131,22 @@ public class RustCoreService : IAsyncDisposable
/// Get the list of table names that need to be synced.
/// </summary>
/// <returns>Array of table names.</returns>
/// <exception cref="InvalidOperationException">Thrown if WASM module is unavailable.</exception>
public async Task<string[]> GetSyncableTableNamesAsync()
{
if (!await IsAvailableAsync())
// Wait for WASM to be available with retries, as it may still be loading.
if (!await WaitForAvailabilityAsync())
{
return SyncableTables.Names;
throw new InvalidOperationException("Rust WASM module is not available.");
}
try
var result = await jsRuntime.InvokeAsync<string[]>("rustCoreGetSyncableTableNames");
if (result == null || result.Length == 0)
{
var result = await jsRuntime.InvokeAsync<string[]>("rustCoreGetSyncableTableNames");
return result ?? SyncableTables.Names;
}
catch
{
return SyncableTables.Names;
throw new InvalidOperationException("Failed to get syncable table names from Rust WASM.");
}
return result;
}
/// <summary>

View File

@@ -1,32 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="SyncableTables.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
//-----------------------------------------------------------------------
namespace AliasVault.Client.Services.JsInterop.RustCore;
/// <summary>
/// List of syncable table names that need to be read for merge operations.
/// </summary>
public static class SyncableTables
{
/// <summary>
/// Table names that need LWW merge.
/// </summary>
public static readonly string[] Names =
[
"Items",
"FieldValues",
"Folders",
"Tags",
"ItemTags",
"Attachments",
"TotpCodes",
"Passkeys",
"FieldDefinitions",
"FieldHistories",
"Logos",
];
}