[Solved] Removing subscribed data

I have the following problem.

  • On page A, I subscribe to a list of data. It contains 25 items.
  • I click on an item. This runs stop on the current subscription handle, and navigates to a detail page
  • The detail page subscribes to the detail of the item.
  • I click a link back to the list of data. This runs stop on the current subscription handle, and navigates to the data list page.

When I navigate back to the list of data, there should be no data in the table, since I’m beginning a new subscription. However, the the item whose detail I was just viewing is already in the table.

What can I do to ensure this doesn’t happen?

edit: gif of the problem

Maybe you could show a loading state in the list view instead of rendering available data in Minimongo if the list subscription handle is not ready? It’s hard to tell if you’re already trying to do this from the GIF alone without code – I see that there is a loading animation, but it looks like you’re probably also going ahead and rendering data even while in a loading state.

I’d probably do the detail view over top of the list view, so that when you go back to the list all you do is hide the detail view, and viola! Instant list.

The problem isn’t that the item is there during loading. It’s that it persists past loading and into the table.

If you notice at the start of the gif, the selected item is not at the top of the list. The list is sorted by profit. After navigating to the detail, and back to the list, the item is now at the top (out of order).

Alright, I’ve fixed this.

My publication was doing the sorting, filtering, and limiting. My client side code was just doing find().fetch(). I added the sort to the client side as well, and that fixed my issue.