fix(web): banner state management after predict-mode toggling

This commit is contained in:
Joshua A. Horton 2023-05-12 14:25:21 +07:00
parent 1cf9e65dc5
commit 84cf3fdca5
2 changed files with 11 additions and 1 deletions

View file

@ -415,9 +415,19 @@ export default class LanguageProcessor extends EventEmitter<LanguageProcessorEve
// If it there was one and we've reached this point, we're globally
// deactivating, so we're fine.
if(this.activeModel) {
// If someone toggles predictions on and off without changing the model, it is possible
// that the model is already configured!
let state: StateChangeEnum = flag ? 'active' : 'inactive';
// We always signal the 'active' state here, even if 'configured', b/c of an
// anti-banner-flicker optimization in the Android app.
this._state = state;
this.emit('statechange', state);
if(this.isConfigured) {
this._state = 'configured';
this.emit('statechange', 'configured');
}
}
}
}

View file

@ -296,7 +296,7 @@ export class BannerController {
*/
selectBanner(state: StateChangeEnum) {
// Only display a SuggestionBanner when LanguageProcessor states it is active.
if(state == 'active') {
if(state == 'active' || state == 'configured') {
this.setBanner('suggestion');
} else if(state == 'inactive') {
if(this.alwaysShow) {