Skip to content

Commit 7a4d1f4

Browse files
committed
add callbacks that allow the frontend to query the current user settings after initialization
1 parent 71382aa commit 7a4d1f4

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

android/tinySSB/app/src/main/assets/web/tremola.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,11 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent
11391139
}
11401140
}
11411141

1142+
// backend callback method when calling backend("settings:get")
1143+
function b2f_get_settings(settings) {
1144+
tremola.settings = settings
1145+
}
1146+
11421147
function b2f_new_contact(fid) {
11431148
if ((fid in tremola.contacts)) // do not overwrite existing entry
11441149
return

android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/WebAppInterface.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ class WebAppInterface(val act: MainActivity, val webView: WebView) {
242242
"settings:set" -> {
243243
act.settings!!.set(args[1], args[2])
244244
}
245+
"settings:get" -> {
246+
val settings = act.settings!!.getSettings()
247+
act.wai.eval("b2f_get_settings('${settings}')")
248+
}
245249
else -> {
246250
Log.d("onFrontendRequest", "unknown")
247251
}

0 commit comments

Comments
 (0)