Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]: Users demo #44

Closed
wants to merge 12 commits into from
Closed

Conversation

snewcomer
Copy link

@snewcomer snewcomer commented Sep 23, 2019

close #43 #51

@snewcomer snewcomer changed the title Fix User Show with handle_params/3 Users demo Dec 2, 2019
@jg-made
Copy link

jg-made commented Dec 4, 2019

@snewcomer I might be doing something wrong locally but when I run your branch and try to delete a user I get an error message:
value `%{"altKey" => false, "ctrlKey" => false, "metaKey" => false, "pageX" => 1255, "pageY" => 180, "screenX" => 1255, "screenY" => 309, "shiftKey" => false, "x" => 1255 , "y" => 180}` in `where` cannot be cast to type :id in query:
It looks like the link being used to delete a user in the index.html template is not sending the user id but instead sending details about the click event.

Thanks for the fork though! I am trying to write a generic master-detail view where the master list updates when a new "thing" is created or when a "thing" is deleted.

@snewcomer
Copy link
Author

@jg-made great find 👍 I fixed and added a test

@jg-made
Copy link

jg-made commented Dec 7, 2019

@snewcomer thanks again! Great work on making it compatible with modern live view.

@jg-made
Copy link

jg-made commented Dec 7, 2019

@snewcomer I have another question please. I see that in user_live/index.ex we have a handle_info/2 function which looks like it is written to handle all kinds of :user changes (:updated, :deleted, etc.).
However, if I have two separate pages open, say the first one on the index list view and say in the second page I delete or update or add a user, the list on the first page does not update. I think maybe the index view has not subscribed to the user socket properly?

UPDATE: OMG i actually figured it out. You need to add this line:

if connected?(socket), do: Demo.Accounts.subscribe()

to the handle_params/3 function in user_live/index.ex.

@snewcomer snewcomer changed the title Users demo [FIX]: Users demo Dec 7, 2019
@@ -11,7 +11,7 @@ defmodule DemoWeb.UserLive.Index do
{:ok, assign(socket, page: 1, per_page: 5)}
end

def handle_params(params, url, socket) do
def handle_params(params, _url, socket) do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this line

if connected?(socket), do: Demo.Accounts.subscribe()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you thank you! Updated and nice job 👍

@snewcomer snewcomer mentioned this pull request Jan 31, 2020
@snewcomer
Copy link
Author

too many merge conflicts

@snewcomer snewcomer closed this Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no function clause matching in DemoWeb.UserLive.Edit.mount/2
2 participants