From 26bffafe7245c0625ce50960c211d1cbabcfcae5 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Wed, 23 Oct 2024 19:57:56 +0200 Subject: [PATCH 1/2] Give sync interval a default value when opening a sync connection to libsql --- cpp/bindings.cpp | 6 ++++-- src/index.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cpp/bindings.cpp b/cpp/bindings.cpp index b471d3d9..098eca1f 100644 --- a/cpp/bindings.cpp +++ b/cpp/bindings.cpp @@ -131,8 +131,10 @@ void install(jsi::Runtime &rt, std::shared_ptr invoker, std::string url = options.getProperty(rt, "url").asString(rt).utf8(rt); std::string auth_token = options.getProperty(rt, "authToken").asString(rt).utf8(rt); - int sync_interval = - static_cast(options.getProperty(rt, "syncInterval").asNumber()); + int sync_interval = 0 if (options.hasProperty(rt, "syncInterval")) { + sync_interval = + static_cast(options.getProperty(rt, "syncInterval").asNumber()); + } std::string location; if (options.hasProperty(rt, "location")) { diff --git a/src/index.ts b/src/index.ts index c9fe6b8e..7f108aeb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -193,6 +193,7 @@ type OPSQLiteProxy = { authToken: string; name: string; location?: string; + syncInterval?: number; }) => DB; isSQLCipher: () => boolean; isLibsql: () => boolean; From 9640a745b7a2aef6c9f9bde79694abfaf3cb1e3a Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Wed, 23 Oct 2024 19:59:05 +0200 Subject: [PATCH 2/2] Fix C++ --- cpp/bindings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/bindings.cpp b/cpp/bindings.cpp index 098eca1f..a4cd737e 100644 --- a/cpp/bindings.cpp +++ b/cpp/bindings.cpp @@ -131,7 +131,8 @@ void install(jsi::Runtime &rt, std::shared_ptr invoker, std::string url = options.getProperty(rt, "url").asString(rt).utf8(rt); std::string auth_token = options.getProperty(rt, "authToken").asString(rt).utf8(rt); - int sync_interval = 0 if (options.hasProperty(rt, "syncInterval")) { + int sync_interval = 0; + if (options.hasProperty(rt, "syncInterval")) { sync_interval = static_cast(options.getProperty(rt, "syncInterval").asNumber()); }