3den/riotjs-todomvc — pull request #4 by rmm5t (2014-06-30 17:29:49+00:00)
Title: Fix refreshes and add/remove behavior while a filter is active

Let the router do it's thing against the footer presenter

* Store the actual filter state instead of the location.hash
* Let the router recognize the location path changes when the browser changes the location.hash instead of manually triggering new routes on click. Less code to worry about.
* Breaking the filter state from the `counts` also serves to properly recognize which footer filter should be "selected" upon a deep link and/or browser refresh. This also allows us to ignore the location.hash pattern. Better separation of concerns.

Modified todo presenter to rely more on reloading

* Added a filter state to the todo presenter
* Instead of manually inserting and removing individual task items and trying to keep the DOM in sync with the model, let the list just re-render itself upon adds, removes, and toggles.
* The nice side effect of this is that adds and toggles automatically
respect the current filter state, which better mimicks all other
todomvc implementations.

To reproduce the bug where the footer doesn't maintain proper state on refreshes and deep-linking:

1. Visit http://www.3den.org/riotjs-todomvc/
2. Add a task (do not mark it as completed; leave it active)
3. Click the "Completed" filter, and note how that filter item is selected (bold).
4. Refresh the browser
5. Notice how the "completed" link in the footer is no longer selected (bold), even though the list is still only showing completed items.

To reproduce the bug where adding a new task while the "Completed" filter is active improperly shows the uncompleted task:

1. Visit http://www.3den.org/riotjs-todomvc/
2. Add a task and mark it as completed
3. Click the "Completed" filter, and note how the completed task is still shown.
4. Add a new task while the completed filter is active.
5. Notice how the uncompleted task now shows up while the completed filter is active. This is undesirable.

There are other broken scenarios like toggling all while either the active or completed filters are currently selected..

If you compare the behavior to other implmentations (like Angular's), you'll see the desired behavior.
http://todomvc.com/architecture-examples/angularjs/

This pull-request fixes all of these broken scenarios.