DEV Community

Discussion on: Modern Rails flash messages (part 2): The undo action for deleted items

Collapse
 
leastbad profile image
leastbad

I really enjoyed this series, Petr.

Did you consider using the Discard gem for your soft undo?

You might want to take a serious look at StimulusReflex, as it would simplify a lot of what you're trying to do; no more fetch or worrying about verification tokens.

I did a version of this concept for one of my apps where I made sure to only display the notification once the browser tab had focus, which actually was a nice touch (and pretty easy to do).

You can also avoid the need to check for Turbolinks previews if you remove the notifications from the DOM before they are cached.

Collapse
 
citronak profile image
Petr Hlavicka

Thank you for your comment. I did this before I've tried and implemented StimulusReflex (also with ViewComponentReflex) for something different in the same app.

Thanks for your suggestions! I will look at more at Turbolinks and when I will have time for refactoring, I will look at how to enhance it 🙂

Collapse
 
leastbad profile image
leastbad

Feel free to ping me on Discord and I'll share the controller with you.