Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Sep 3, 2024
1 parent 58edb8d commit 68b101d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/happyx_native/abstract/saving.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions src/happyx_native/android/autils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/happyx_native/app/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 68b101d

Please sign in to comment.