Sync text zoom preference through the account instead of local settings

Local user://settings.cfg meant zoom level didn't follow a student
across devices/browsers. Question bank and CCS text scale now live on
the user's study profile in Mongo (QuestionTextScale/CcsTextScale),
synced through a new PUT /api/profile/me/text-scale endpoint and the
existing preferences GET/cache already used for study preferences.

Both question_player.gd and ccs_service.gd read the synced value at
startup and react to AccountProfileService.profile_changed so a value
pulled down after login (or changed from another session) applies
without a restart. Backend validates the 0.85-1.35 range and updates
only the field(s) provided via a targeted $set, so it can't clobber
the other scale or the unrelated study-profile preferences.
This commit is contained in:
hz
2026-07-23 03:59:02 -05:00
parent b88f38f29b
commit d69a1fd0e3
10 changed files with 124 additions and 36 deletions
+19 -2
View File
@@ -84,6 +84,20 @@ func update_preferences(target_exam_date: String, preparation_stage: String, wee
_request_profile("update_preferences", HTTPClient.METHOD_PUT, "/me/preferences", preferences)
func update_text_scale(question_text_scale: Variant = null, ccs_text_scale: Variant = null) -> void:
var payload := {}
if question_text_scale != null:
payload["questionTextScale"] = question_text_scale
preferences["questionTextScale"] = question_text_scale
if ccs_text_scale != null:
payload["ccsTextScale"] = ccs_text_scale
preferences["ccsTextScale"] = ccs_text_scale
if payload.is_empty():
return
_save_cache(preferences_pending)
_request_profile("update_text_scale", HTTPClient.METHOD_PUT, "/me/text-scale", payload)
func change_password(current_password: String, new_password: String) -> void:
_request_auth("change_password", HTTPClient.METHOD_POST, "/me/change-password", {
"currentPassword": current_password, "newPassword": new_password
@@ -192,7 +206,7 @@ func _on_profile_completed(result: int, response_code: int, _headers: PackedStri
if typeof(parsed) != TYPE_DICTIONARY:
request_failed.emit("The profile service returned invalid data.")
return
if operation in ["preferences", "update_preferences"]:
if operation in ["preferences", "update_preferences", "update_text_scale"]:
preferences = parsed
preferences_pending = false
_save_cache(false)
@@ -345,4 +359,7 @@ func _error_message(body: PackedByteArray, fallback: String) -> String:
static func _default_preferences() -> Dictionary:
return {"targetExamDate": null, "preparationStage": "pre_dedicated", "weeklyGoalHours": 10, "preferredStudyMode": "mixed"}
return {
"targetExamDate": null, "preparationStage": "pre_dedicated", "weeklyGoalHours": 10, "preferredStudyMode": "mixed",
"questionTextScale": 1.0, "ccsTextScale": 1.0
}