@@ -16,6 +16,7 @@ var colors = ["#d9ceb2", "#99b2b7", "#e6cba5", "#ede3b4", "#8b9e9b", "#bd7578",
1616var curr_img_candidate = null ;
1717var pubs = [ ]
1818var wants = { }
19+ var loaded_settings = { } // the settings provided bz the backend, will overwrite tremola.settings after initialization
1920
2021var restream = false // whether the backend is currently restreaming all posts
2122
@@ -856,7 +857,7 @@ function resetTremola() { // wipes browser-side content
856857 "contacts" : { } ,
857858 "profile" : { } ,
858859 "id" : myId ,
859- "settings" : get_default_settings ( ) ,
860+ "settings" : { } ,
860861 "board" : { }
861862 }
862863 var n = recps2nm ( [ myId ] )
@@ -921,63 +922,6 @@ function b2f_ble_disabled() {
921922 //ble_status = "disabled"
922923}
923924
924- /*
925- var want = {} // all received want vectors, id: [[want vector], timestamp], want vectors older than 90 seconds are discarded
926- var max_want = [] // current max vector
927- var old_curr = [] // own want vector at the time when the maximum want vector was last updated
928-
929- function b2f_want_update(identifier, wantVector) {
930-
931- console.log("b2f received want:", wantVector, "from: ", identifier)
932-
933- // remove old want vectors
934- var deleted = false;
935- for (var id in want) {
936- var ts = want[id][1]
937- if(Date.now() - ts > 90000) {
938- console.log("removed want of", id)
939- delete want[id]
940- deleted = true
941- }
942-
943- }
944-
945- // if the want vector didn't change, no further updates are required
946- if(identifier in want) {
947- if( equalArrays(want[identifier][0], wantVector)) {
948- console.log("update only")
949- want[identifier][1] = Date.now()
950- if(!deleted) //if a want vector was previously removed, the max_want needs to be recalculated otherwise it is just an update without an effect
951- return
952- }
953- }
954-
955- want[identifier] = [wantVector, Date.now()]
956-
957- // calculate new max want vector
958- var all_vectors = Object.values(want).map(val => val[0])
959- var new_max_want = all_vectors.reduce((accumulator, curr) => accumulator.len >= curr.len ? accumulator : curr) //return want vector with most entries
960-
961- for (var vec of all_vectors) {
962- for(var i in vec) {
963- if (vec[i] > new_max_want[i])
964- new_max_want[i] = vec[i]
965- }
966- }
967-
968- // update
969- if (!equalArrays(max_want,new_max_want)) {
970- old_curr = want['me'][0]
971- max_want = new_max_want
972- console.log("new max")
973- }
974-
975- refresh_connection_progressbar()
976-
977- console.log("max:", max_want)
978- }
979- */
980-
981925function b2f_local_peer_remaining_updates ( identifier , remaining ) {
982926 //TODO
983927}
@@ -1195,6 +1139,11 @@ function b2f_new_event(e) { // incoming SSB log event: we get map with three ent
11951139 }
11961140}
11971141
1142+ // backend callback method when calling backend("settings:get")
1143+ function b2f_get_settings ( settings ) {
1144+ tremola . settings = settings
1145+ }
1146+
11981147function b2f_new_contact ( fid ) {
11991148 if ( ( fid in tremola . contacts ) ) // do not overwrite existing entry
12001149 return
@@ -1232,7 +1181,7 @@ function b2f_new_image_blob(ref) {
12321181 overlayIsActive = true ;
12331182}
12341183
1235- function b2f_initialize ( id ) {
1184+ function b2f_initialize ( id , settings ) {
12361185 myId = id
12371186 if ( window . localStorage . tremola ) {
12381187 tremola = JSON . parse ( window . localStorage . getItem ( 'tremola' ) ) ;
@@ -1244,11 +1193,13 @@ function b2f_initialize(id) {
12441193 if ( tremola == null ) {
12451194 resetTremola ( ) ;
12461195 console . log ( "reset tremola" )
1196+ if ( typeof Android == 'undefined' )
1197+ tremola . settings = BrowserOnlySettings // browser-only testing
12471198 }
12481199 if ( typeof Android == 'undefined' )
12491200 console . log ( "loaded " , JSON . stringify ( tremola ) )
1250- if ( ! ( 'settings' in tremola ) )
1251- tremola . settings = { }
1201+ else
1202+ tremola . settings = JSON . parse ( settings )
12521203 var nm , ref ;
12531204 for ( nm in tremola . settings )
12541205 setSetting ( nm , tremola . settings [ nm ] )
@@ -1261,4 +1212,7 @@ function b2f_initialize(id) {
12611212 // load_chat("ALL");
12621213}
12631214
1215+
1216+
1217+
12641218// --- eof
0 commit comments