Skip to content

Conversation

Arley011
Copy link

@Arley011 Arley011 commented Apr 17, 2025

This improvement gives more control over recent emojis list updates in widget's state.

Now user can set recentEmojisUpdatePolicy parameter in CategoryViewConfig to define whether recent emojis list in the widget's state should update:

  • never - never updates the list for Recent tab
  • notFromRecent - updates the list only when selected emoji is NOT from Recent category
  • always - always updates the list.

I added this improvement because even though there was a logic to skip setState() calls when selected emoji is from Recent category, my widget's build() can sometimes be triggered from the parent widget. This was leading to strange behaviour.

NOTE: Removed old logic that was updating the emojis list state, but was not calling setState() if the selected emoji was from Recent category. Now whole updateRecentEmoji() is getting called based on recentEmojisUpdatePolicy.

@alex-melnyk
Copy link

@Fintasys could you please review this PR?

@Fintasys
Copy link
Owner

Thanks for you PR 🙇

I added this improvement because even though there was a logic to skip setState() calls when selected emoji is from Recent category, my widget's build() can sometimes be triggered from the parent widget. This was leading to strange behaviour.

I think the current existing logic is fine. If your build method is triggered for other reasons (which is fine) it shouldn't affect the EmojiPicker as stateful widget. Did you try to find the root cause of this strange behavior?

@Arley011
Copy link
Author

Arley011 commented Aug 26, 2025

I think the current existing logic is fine.

The problem is that the logic is inconsistent. In some cases, it updates the list in the state, but doesn't update the UI. In other cases, it updates both the state and UI by calling setState. And the developer has no options to configure this behaviour.
In my opinion, if the state is updated, then the UI should always be updated to reflect changes. Otherwise, what's the point of updating the state? So if we don't want to update the UI (e.g. when we want to prevent Recent category from real-time update), we shouldn't update the state.

If your build method is triggered for other reasons (which is fine) it shouldn't affect the EmojiPicker as stateful widget.

It will affect the EmojiPicker because Recent Emojis list is getting updated with refresh: false, which doesn't trigger the UI rebuild right after selecting an emoji. But if a rebuild will happen because of the parent widget, the list of recent emojis will be re-ordered according to the last state update (and it can happen in reaction to some random action that is not related to Emoji Picker widget).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants