Managing lifecycle of Notifiers when also rendering notifications on views/controllers #547
Unanswered
sergioisidoro
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
First of all, thanks for the work on this gem. We've been using if for quite a long time :)
While migrating to 2.x we've come across some challenges, specifically about the default behaviour of saving the notification in the db. It makes sense, and we want to migrate to this way of doing things, but it comes with a challenge - Dynamically "rendering" messages like in the docs breaks things as data and code evolves. We would like hear your oppinion and perhaps help document this case.
eg. Let's imagine that we have a notification
NewMessageNotifier, with a class method, and the same example as in the docsAnd in a view:
Let's imagine now that we have a new version of the notifier, or that we don't need it anymore (no new notifications for this notifier) and delete
NewMessageNotifier, or that message.type is no logner used and is dropped from the db. Things get strange. We always need to keep the notifiers backwards compatibilty if we want to keep a history of notifications.The current architecture basically implies that once a Notifier is created (inc. translations) they cannot be delete or removed otherwise older notifications won'be be renderable anymore on a web view, or will be rendered differently than from when created.
In v1 we managed this by having a delivery method that would bypass the
Notificationmodel, and created a separare "rendered" model in the db that are basically strings. They no longer depend on any data, context, or translation keys.This way we had a standard way of always rendering a message in the UI, regardless if the notifer no longer exists, translation key changes, etc. The obvious drawback is that the notfications are rendered at the time of delivery, so if the user changes their language it won't change the old notifications.
I'm guessing the "proper" way to do this now would be to create an extension to the Notification, add additional fields to the table with the migration, and use the
recipient_attributes_forto generate additional attributes to theNotificationobject?That is, at least, what I can read from here
noticed/app/models/concerns/noticed/deliverable.rb
Line 100 in fae78f9
I'm wondering if someone else has encountered this issue, and how they resolved it?
Beta Was this translation helpful? Give feedback.
All reactions