Skip to content

Conversation

Diaglyonok
Copy link

Updated RecyclerView so it's no longer re-creates all the view every update from JS Bridge. Used DiffUtil to calculate diff and make updates only for changed ones.

Alternative way to fix: The issue could be addressed at the ViewModel level first by reducing frequent state emissions, rather than introducing DiffUtil if that’s not the standard approach in the project.

Updated RecyclerView so it's no longer re-creates all the view every update from JS Bridge. Used DiffUtil to calculate diff and make updates only for changed ones.
Copy link

netlify bot commented Oct 16, 2025

👷 Deploy request for mytonwallet-tma pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b043041

Copy link

netlify bot commented Oct 16, 2025

👷 Deploy request for mtw-opensource pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b043041

Copy link

netlify bot commented Oct 16, 2025

👷 Deploy request for mtw-giveaway pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b043041

override fun isSame(comparing: WEquatable<*>): Boolean {
return if (comparing is EarnItem && comparing::class == this::class) {
comparing.timestamp == timestamp && comparing.amount == amount
comparing.timestamp == timestamp && comparing.amount == amount && comparing.amountInBaseCurrency == amountInBaseCurrency
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSame should compare identifiers (or similar unique properties) to check if two instances refer to the same item. Comparing amountInBaseCurrency shouldn't be necessary here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


val diffResult = DiffUtil.calculateDiff(diffCallback)
previousHistoryItems = newItems.toList() // Store copy for next comparison
diffResult.dispatchUpdatesTo(rvAdapter)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using List<WEquatable<*>>.diff and WRecyclerViewAdapter.applyChanges? Did you try to use that instead? It should be ready-to-use and probably easier to apply to all the necessary screens.

Copy link
Author

@Diaglyonok Diaglyonok Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks, didn't notice that utils. Fixed

Copy link

@Sina-KH Sina-KH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my comments.

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.

2 participants