fix: disable emoji setting for non-L2 constructs (#5148)
This commit is contained in:
parent
ec2e2f3dbd
commit
33d8df3125
2 changed files with 20 additions and 2 deletions
|
|
@ -13,9 +13,17 @@ import 'package:fluffychat/widgets/matrix.dart';
|
|||
mixin LemmaEmojiSetter {
|
||||
Future<void> setLemmaEmoji(
|
||||
ConstructIdentifier constructId,
|
||||
String langCode,
|
||||
String emoji,
|
||||
String? targetId,
|
||||
) async {
|
||||
final userL2 =
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort;
|
||||
if (langCode.split("-").first != userL2) {
|
||||
// only set emoji for user's L2 language
|
||||
return;
|
||||
}
|
||||
|
||||
if (constructId.userSetEmoji == null) {
|
||||
_getEmojiAnalytics(
|
||||
constructId,
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ class LemmaReactionPickerState extends State<LemmaReactionPicker> {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
bool get _enabled =>
|
||||
(widget.langCode.split("-").first ==
|
||||
MatrixState.pangeaController.userController.userL2?.langCodeShort) &&
|
||||
widget.enabled;
|
||||
|
||||
void _setEmojiSub() {
|
||||
_emojiSub?.cancel();
|
||||
_emojiSub = Matrix.of(context)
|
||||
|
|
@ -90,7 +95,12 @@ class LemmaReactionPickerState extends State<LemmaReactionPicker> {
|
|||
String emoji,
|
||||
String targetId,
|
||||
) async {
|
||||
await widget.setLemmaEmoji(widget.constructId, emoji, targetId);
|
||||
await widget.setLemmaEmoji(
|
||||
widget.constructId,
|
||||
widget.langCode,
|
||||
emoji,
|
||||
targetId,
|
||||
);
|
||||
messenger = ScaffoldMessenger.of(context);
|
||||
widget.showLemmaEmojiSnackbar(
|
||||
messenger!,
|
||||
|
|
@ -145,7 +155,7 @@ class LemmaReactionPickerState extends State<LemmaReactionPicker> {
|
|||
size: 12.0,
|
||||
)
|
||||
: null,
|
||||
enabled: widget.enabled,
|
||||
enabled: _enabled,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue