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.
I am a freelance web developer since 2007. I’ve started as HTML & CSS coder (in time of IE 6). Then as PHP (and WordPress) developer. Since 2015, I am working with Ruby on Rails.
Location
Prague, Czech Republic
Education
Master of Business Informatics, University of Economics, Prague
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 🙂
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.
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 🙂
Feel free to ping me on Discord and I'll share the controller with you.