edisonywh / backoffice

Admin tool built with the PETAL stack
MIT License
217 stars 15 forks source link

Add Notification & push_notification/2 #32

Closed edisonywh closed 3 years ago

edisonywh commented 3 years ago

Video: https://cln.sh/1dS7AJ

There's also a slight caveat, you can't use push_redirect with push_notification, because push_redirect doesn't work with push_event (which is what push_notification uses under the hood). For that reason, Backoffice provides a callback so you can still do redirection, just do push_notification(socket, redirect: url).

edisonywh commented 3 years ago

https://github.com/phoenixframework/phoenix_live_view/blob/v0.15.4/lib/phoenix_live_view/utils.ex#L208-L214

This is relevant, it doesn't "survive a live_direct" is not exactly true, more accurately, the push_event isn't even fired in the first place, because of the push_redirect. Not sure where to go from here..