chore: refresh choreographer on change learning settings (#2155)
This commit is contained in:
parent
83bcf95f2e
commit
5326b3684b
10 changed files with 34 additions and 21 deletions
|
|
@ -615,7 +615,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
inputFocus.removeListener(_inputFocusListener);
|
||||
onFocusSub?.cancel();
|
||||
//#Pangea
|
||||
choreographer.stateListener.close();
|
||||
choreographer.stateStream.close();
|
||||
choreographer.dispose();
|
||||
clearSelectedEvents();
|
||||
MatrixState.pAnyState.closeOverlay();
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ class ChatFloatingActionButtonState extends State<ChatFloatingActionButton> {
|
|||
}
|
||||
|
||||
// Rebuild the widget each time there's an update from choreo (i.e., an error).
|
||||
_choreoSub =
|
||||
widget.controller.choreographer.stateListener.stream.listen((_) {
|
||||
_choreoSub = widget.controller.choreographer.stateStream.stream.listen((_) {
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ChatViewBackgroundState extends State<ChatViewBackground> {
|
|||
@override
|
||||
void initState() {
|
||||
// Rebuild the widget each time there's an update from choreo
|
||||
_choreoSub = widget.choreographer.stateListener.stream.listen((_) {
|
||||
_choreoSub = widget.choreographer.stateStream.stream.listen((_) {
|
||||
setState(() {});
|
||||
});
|
||||
super.initState();
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ class ChatInputRowWrapperState extends State<ChatInputRowWrapper> {
|
|||
@override
|
||||
void initState() {
|
||||
// Rebuild the widget each time there's an update from choreo
|
||||
_choreoSub =
|
||||
widget.controller.choreographer.stateListener.stream.listen((_) {
|
||||
_choreoSub = widget.controller.choreographer.stateStream.stream.listen((_) {
|
||||
setState(() {});
|
||||
});
|
||||
super.initState();
|
||||
|
|
|
|||
|
|
@ -55,8 +55,10 @@ class Choreographer {
|
|||
// last checked by IGC or translation
|
||||
String? _lastChecked;
|
||||
ChoreoMode choreoMode = ChoreoMode.igc;
|
||||
final StreamController stateListener = StreamController.broadcast();
|
||||
StreamSubscription? trialStream;
|
||||
|
||||
final StreamController stateStream = StreamController.broadcast();
|
||||
StreamSubscription? _trialStream;
|
||||
StreamSubscription? _languageStream;
|
||||
|
||||
Choreographer(this.pangeaController, this.chatController) {
|
||||
_initialize();
|
||||
|
|
@ -74,9 +76,20 @@ class Choreographer {
|
|||
errorService = ErrorService(this);
|
||||
altTranslator = AlternativeTranslator(this);
|
||||
_textController.addListener(_onChangeListener);
|
||||
trialStream = pangeaController
|
||||
_trialStream = pangeaController
|
||||
.subscriptionController.trialActivationStream.stream
|
||||
.listen((_) => _onChangeListener);
|
||||
_languageStream =
|
||||
pangeaController.userController.stateStream.listen((update) {
|
||||
if (update is Map<String, dynamic> &&
|
||||
update['prev_target_lang'] is LanguageModel) {
|
||||
clear();
|
||||
}
|
||||
|
||||
// refresh on any profile update, to account
|
||||
// for changes like enabling autocorrect
|
||||
setState();
|
||||
});
|
||||
clear();
|
||||
}
|
||||
|
||||
|
|
@ -560,7 +573,9 @@ class Choreographer {
|
|||
|
||||
dispose() {
|
||||
_textController.dispose();
|
||||
trialStream?.cancel();
|
||||
_trialStream?.cancel();
|
||||
_languageStream?.cancel();
|
||||
stateStream.close();
|
||||
tts.dispose();
|
||||
}
|
||||
|
||||
|
|
@ -617,8 +632,8 @@ class Choreographer {
|
|||
bool get editTypeIsKeyboard => EditType.keyboard == _textController.editType;
|
||||
|
||||
setState() {
|
||||
if (!stateListener.isClosed) {
|
||||
stateListener.add(0);
|
||||
if (!stateStream.isClosed) {
|
||||
stateStream.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class ITBarState extends State<ITBar> with SingleTickerProviderStateMixin {
|
|||
super.initState();
|
||||
|
||||
// Rebuild the widget each time there's an update from choreo.
|
||||
_choreoSub = widget.choreographer.stateListener.stream.listen((_) {
|
||||
_choreoSub = widget.choreographer.stateStream.stream.listen((_) {
|
||||
if (itController.willOpen != wasOpen) {
|
||||
itController.willOpen ? _controller.forward() : _controller.reverse();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ class ChoreographerSendButtonState extends State<ChoreographerSendButton> {
|
|||
void initState() {
|
||||
// Rebuild the widget each time there's an update from
|
||||
// choreo. This keeps the spin up-to-date.
|
||||
_choreoSub =
|
||||
widget.controller.choreographer.stateListener.stream.listen((_) {
|
||||
_choreoSub = widget.controller.choreographer.stateStream.stream.listen((_) {
|
||||
setState(() {});
|
||||
});
|
||||
super.initState();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class StartIGCButtonState extends State<StartIGCButton>
|
|||
vsync: this,
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
_choreoListener = widget.controller.choreographer.stateListener.stream
|
||||
_choreoListener = widget.controller.choreographer.stateStream.stream
|
||||
.listen(_updateSpinnerState);
|
||||
super.initState();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,10 +85,11 @@ class UserController extends BaseController {
|
|||
|
||||
final Profile updatedProfile = update(profile);
|
||||
await updatedProfile.saveProfileData(waitForDataInSync: waitForDataInSync);
|
||||
|
||||
if (prevTargetLang != _pangeaController.languageController.userL2) {
|
||||
setState({'prev_target_lang': prevTargetLang});
|
||||
}
|
||||
setState(
|
||||
prevTargetLang != _pangeaController.languageController.userL2
|
||||
? {'prev_target_lang': prevTargetLang}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// A completer for the profile model of a user.
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class WritingAssistanceInputRowState extends State<WritingAssistanceInputRow> {
|
|||
@override
|
||||
void initState() {
|
||||
// Rebuild the widget each time there's an update from choreo
|
||||
_choreoSub = choreographer.stateListener.stream.listen((_) {
|
||||
_choreoSub = choreographer.stateStream.stream.listen((_) {
|
||||
setSuggestions();
|
||||
});
|
||||
setSuggestions();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue