Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Retrieve SyncableTables info from Rust Core (#1404)

Leendert de Borst96e68b2bcee0
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs
index 13664c07e..1c1a825d2 100644
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs
+++ b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/RustCoreService.cs
@@ -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>
diff --git a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SyncableTables.cs b/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SyncableTables.cs
deleted file mode 100644
index 7156405db..000000000
--- a/apps/server/AliasVault.Client/Services/JsInterop/RustCore/SyncableTables.cs
+++ /dev/null
@@ -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",
- ];
-}