diff --git a/src/happyx_native/abstract/saving.nim b/src/happyx_native/abstract/saving.nim index 89bc93d..82d057f 100644 --- a/src/happyx_native/abstract/saving.nim +++ b/src/happyx_native/abstract/saving.nim @@ -75,6 +75,8 @@ template loadImpl[T](filename: string, parseFunc: untyped): untyped = when T is string: return $sharedPreferences.getString(filename, "") else: + if ($sharedPreferences.getString(filename, "")).len == 0: + return T.default return `parseFunc`($sharedPreferences.getString(filename, "")) else: if not dirExists(getHomeDir() / "hpxnative"): @@ -89,6 +91,8 @@ template loadImpl[T](filename: string, parseFunc: untyped): untyped = when T is string: return data else: + if $data.len == 0: + return T.default return `parseFunc`($data) diff --git a/src/happyx_native/android/autils.nim b/src/happyx_native/android/autils.nim index 8f670a0..5c287a6 100644 --- a/src/happyx_native/android/autils.nim +++ b/src/happyx_native/android/autils.nim @@ -146,7 +146,7 @@ jClass android.content.SharedPreferences$Editor as SharedPreferencesEditor* of O proc putInt*(key: string, value: jint): SharedPreferencesEditor proc putLong*(key: string, value: jlong): SharedPreferencesEditor proc putString*(key: string, value: string): SharedPreferencesEditor - proc putStringSet*(key: string, value: Set[string]): SharedPreferencesEditor + # proc putStringSet*(key: string, value: Set[string]): SharedPreferencesEditor proc remove*(key: string): SharedPreferencesEditor @@ -159,7 +159,7 @@ jClass android.content.SharedPreferences of Object: proc getInt*(key: string, defValue: jint): jint proc getLong*(key: string, defValue: jlong): jlong proc getString*(key: string, defValue: string): string - proc getStringSet*(key: string, defValue: Set[string]): Set[string] + # proc getStringSet*(key: string, defValue: Set[string]): Set[string] jClass android.graphics.Rect* of Object: diff --git a/src/happyx_native/app/app.nim b/src/happyx_native/app/app.nim index 972ed4b..b9e4702 100644 --- a/src/happyx_native/app/app.nim +++ b/src/happyx_native/app/app.nim @@ -360,6 +360,7 @@ template nativeAppImpl*(appDirectory: string = "/assets", port: int = 5123, ); hpxNative.callJs(v[0], v[1]); } + ws.onopen = () => {connected = true}; var hpxNative = { callJs: function (func, arr) { window[func].apply(null, arr);