chore: update bot target gender on user settings gender update (#5528)

This commit is contained in:
ggurdin 2026-01-30 09:36:04 -05:00 committed by GitHub
parent 6058d12255
commit 67a1f1ee93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:fluffychat/pangea/chat_settings/constants/bot_mode.dart';
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
import 'package:fluffychat/pangea/learning_settings/gender_enum.dart';
import 'package:fluffychat/pangea/learning_settings/language_level_type_enum.dart';
class BotOptionsModel {
@ -23,6 +24,7 @@ class BotOptionsModel {
final String? textAdventureGameMasterInstructions;
final String? targetLanguage;
final String? targetVoice;
final GenderEnum targetGender;
const BotOptionsModel({
////////////////////////////////////////////////////////////////////////////
@ -35,6 +37,7 @@ class BotOptionsModel {
this.mode = BotMode.discussion,
this.targetLanguage,
this.targetVoice,
this.targetGender = GenderEnum.unselected,
////////////////////////////////////////////////////////////////////////////
// Discussion Mode Options
@ -73,6 +76,12 @@ class BotOptionsModel {
mode: json[ModelKey.mode] ?? BotMode.discussion,
targetLanguage: json[ModelKey.targetLanguage],
targetVoice: json[ModelKey.targetVoice],
targetGender: json[ModelKey.targetGender] != null
? GenderEnum.values.firstWhere(
(g) => g.name == json[ModelKey.targetGender],
orElse: () => GenderEnum.unselected,
)
: GenderEnum.unselected,
//////////////////////////////////////////////////////////////////////////
// Discussion Mode Options
@ -121,6 +130,7 @@ class BotOptionsModel {
data[ModelKey.customTriggerReactionKey] = customTriggerReactionKey ?? "";
data[ModelKey.textAdventureGameMasterInstructions] =
textAdventureGameMasterInstructions;
data[ModelKey.targetGender] = targetGender.name;
return data;
} catch (e, s) {
debugger(when: kDebugMode);
@ -149,6 +159,7 @@ class BotOptionsModel {
String? textAdventureGameMasterInstructions,
String? targetLanguage,
String? targetVoice,
GenderEnum? targetGender,
}) {
return BotOptionsModel(
languageLevel: languageLevel ?? this.languageLevel,
@ -172,6 +183,7 @@ class BotOptionsModel {
this.textAdventureGameMasterInstructions,
targetLanguage: targetLanguage ?? this.targetLanguage,
targetVoice: targetVoice ?? this.targetVoice,
targetGender: targetGender ?? this.targetGender,
);
}
}

View file

@ -59,10 +59,12 @@ extension BotClientExtension on Client {
final targetLanguage = userSettings.targetLanguage;
final languageLevel = userSettings.cefrLevel;
final voice = userSettings.voice;
final gender = userSettings.gender;
if (botOptions.targetLanguage == targetLanguage &&
botOptions.languageLevel == languageLevel &&
botOptions.targetVoice == voice) {
botOptions.targetVoice == voice &&
botOptions.targetGender == gender) {
continue;
}
@ -70,6 +72,7 @@ extension BotClientExtension on Client {
targetLanguage: targetLanguage,
languageLevel: languageLevel,
targetVoice: voice,
targetGender: gender,
);
futures.add(targetBotRoom.setBotOptions(updated));
}

View file

@ -132,6 +132,7 @@ class ModelKey {
static const String targetLanguage = "target_language";
static const String sourceLanguage = "source_language";
static const String targetVoice = "target_voice";
static const String targetGender = "users_genders";
static const String prevEventId = "prev_event_id";
static const String prevLastUpdated = "prev_last_updated";