Skip to content

Conversation

@RafaelKayumov
Copy link
Contributor

@RafaelKayumov RafaelKayumov commented Dec 8, 2025

WOOMOB-47

Description

Makes "Most recent orders" dashboard card to reflect order status updates. In the original implementation orders were fetched from API bypassing local storage and were presented in card as-is. Thus the presented orders were detached from the local storage state and didn't reflect any changes.

In this branch the EntityListener was used to track and reflect order changes in dashboard card following the same approach as in #16380. Thx to @itsmeichigo for the suggestion.

  • Creates Order entity listeners for each order presented in the card.
  • Adds/Deletes/Re-creates the corresponding entity listeners in case if the set of displayed orders changes.
  • Doesn't track/maintain the collection of orders basing on Core Data state. The orders set presented in dashboard card is still fetched from API directly.
  • Additionally unsubscribes the the entity listener on deinit for safety.

Test Steps

  • In dashboard display the "Most recent orders" card and make sure there is at least one order.
  • Navigate to the order and change the order status to a different one.
  • Navigate back to the dashboard card. Make sure there was no pull-to-refresh action on dashboard or any other manual update.
  • Make sure the order displays the new selected status in the "Most recent orders" dashboard card.

Demo

dashboardCardOrderUpdateDemo.mov

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@RafaelKayumov RafaelKayumov added this to the 23.9 milestone Dec 8, 2025
@RafaelKayumov RafaelKayumov added the type: task An internally driven task. label Dec 8, 2025
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 8, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16442-d73e09b
Version23.8
Bundle IDcom.automattic.alpha.woocommerce
Commitd73e09b
Installation URL4g6ulttojdvuo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@RafaelKayumov RafaelKayumov marked this pull request as ready for review December 10, 2025 10:47
@itsmeichigo itsmeichigo self-assigned this Dec 11, 2025
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

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

Thanks for working on this Rafael! I shared some concerns below.

guard let index = rows.firstIndex(where: { $0.id == order.orderID }) else {
return
}
rows[index] = LastOrderDashboardRowViewModel(order: order)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check only for relevant updates? Changes like custom fields and customer notes should not affect the row on the card. Maybe check for changes in status, customer name, and cost - basically things that are displayed on the card only?

Also, should we reload the card to get the latest orders if status is changed? Otherwise we'll show orders with mismatched status like this:

Simulator.Screen.Recording.-.iPhone.17.-.2025-12-11.at.09.33.03.mov


func removeRow(with orderID: Int64) {
rows.removeAll { $0.id == orderID }
orderEntityListeners[orderID] = nil
Copy link
Contributor

@itsmeichigo itsmeichigo Dec 11, 2025

Choose a reason for hiding this comment

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

Similar comment as above - we should reload the card to get 3 last orders. If all 3 orders are trashed, the card will be left with no item even though there might be more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants