Repository navigation
Keep stories unread through a form and Turbo Stream - #1708
Merged
Merged
Conversation
**What** The keep unread button is now a form that patches `/stories/:id/keep_unread`. The new `keep_unread` action saves the story and responds with a Turbo Stream that replaces the form, so the checkbox only changes once the save has worked. The form carries the saved read and keep unread state and is the `story` controller's `readState` target. When a new one connects, the controller copies that state onto the story's classes and announces the change for the unread count. Remove the `keep-unread-toggle` controller. Replace `StoryStarStream` with a generic `ReplaceStream` component used by both actions. **Why** Next step in moving story updates to server-confirmed forms, so the shared Stimulus controllers no longer talk to the server. **Notes** Merge the action button reset into their shared CSS rule, which also fixes its property order and lowers the stylelint baseline. Several system specs reloaded the page right after toggling keep unread. They now wait for the saved state first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The keep unread button is now a form that patches
/stories/:id/keep_unread. The newkeep_unreadaction saves thestory and responds with a Turbo Stream that replaces the form, so the
checkbox only changes once the save has worked.
The form carries the saved read and keep unread state and is the
storycontroller'sreadStatetarget. When a new one connects, thecontroller copies that state onto the story's classes and announces
the change for the unread count.
Remove the
keep-unread-togglecontroller. ReplaceStoryStarStreamwith a generic
ReplaceStreamcomponent used by both actions.Why
Next step in moving story updates to server-confirmed forms, so the
shared Stimulus controllers no longer talk to the server.
Notes
Merge the action button reset into their shared CSS rule, which also
fixes its property order and lowers the stylelint baseline.
Several system specs reloaded the page right after toggling keep
unread. They now wait for the saved state first.