chirp
chirp copied to clipboard
The delete function does not trigger live update.
I opened two windows side by side, the create/edit/increment_tweets, increment_retweets works fine.
However, the delete function does not work. Here is the trace info:
[error] GenServer #PID<0.677.0> terminating ** (Ecto.NoResultsError) expected at least one result but got none in query:
from p0 in Chirp.Timeline.Post, where: p0.id == ^"8"
(ecto 3.4.2) lib/ecto/repo/queryable.ex:122: Ecto.Repo.Queryable.one!/3
(chirp 0.1.0) lib/chirp_web/live/post_live/index.ex:38: ChirpWeb.PostLive.Index.handle_event/3
(phoenix_live_view 0.12.1) lib/phoenix_live_view/channel.ex:89: Phoenix.LiveView.Channel.handle_info/2
(stdlib 3.14) gen_server.erl:689: :gen_server.try_dispatch/4
(stdlib 3.14) gen_server.erl:765: :gen_server.handle_msg/6
(stdlib 3.14) proc_lib.erl:236: :proc_lib.wake_up/3
Last message: %Phoenix.Socket.Message{event: "event", join_ref: "78", payload: %{"event" => "delete", "type" => "click", "value" => %{"altKey" => false, "ctrlKey" => false, "detail" => 1, "id" => "8", "metaKey" => false, "offsetX" => 10, "offsetY" => 8, "pageX" => 492, "pageY" => 408, "screenX" => 1543, "screenY" => 645, "shiftKey" => false, "x" => 492, "y" => 408}}, ref: "88", topic: "lv:phx-Fl_OSsjJhli7QAaK"} State: %{components: {%{{ChirpWeb.PostLive.PostComponent, 8} => {1, %{flash: %{}, id: 8, myself: 1, post: %Chirp.Timeline.Post{meta: #Ecto.Schema.Metadata<:loaded, "posts">, body: "3rd post", id: 8, inserted_at: ~N[2021-02-02 02:40:04], likes_count: 0, reposts_count: 0, updated_at: ~N[2021-02-02 02:40:04], username: "dersnek"}}, %{}, {261004382012615277393717461097428235032, %{}}}, {ChirpWeb.PostLive.PostComponent, 9} => {0, %{flash: %{}, id: 9, myself: 0, post: %Chirp.Timeline.Post{meta: #Ecto.Schema.Metadata<:loaded, "posts">, body: "sss", id: 9, inserted_at: ~N[2021-02-02 02:46:52], likes_count: 0, reposts_count: 0, updated_at: ~N[2021-02-02 02:46:52], username: "dersnek"}}, %{}, {261004382012615277393717461097428235032, %{}}}}, %{0 => {ChirpWeb.PostLive.PostComponent, 9}, 1 => {ChirpWeb.PostLive.PostComponent, 8}}, 2}, join_ref: "78", serializer: Phoenix.Socket.V2.JSONSerializer, socket: #Phoenix.LiveView.Socket<assigns: %{flash: %{}, live_action: :index, live_module: ChirpWeb.PostLive.Index, page_title: "Listing Posts", post: nil, posts: []}, changed: %{}, endpoint: ChirpWeb.Endpoint, id: "phx-Fl_OSsjJhli7QAaK", parent_pid: nil, root_pid: #PID<0.677.0>, router: ChirpWeb.Router, view: ChirpWeb.PostLive.Index, ...>, topic: "lv:phx-Fl_OSsjJhli7QAaK", transport_pid: #PID<0.585.0>, uri: %URI{authority: nil, fragment: nil, host: "localhost", path: nil, port: 4000, query: nil, scheme: "http", userinfo: nil}}
Hi @adam-jian-zhang, thanks for pointing out this issue! I am aware of this, it is a bug that is present in a tutorial. I might fix it a bit later, but I don't have time currently. If you see an easy fix, please feel free to submit a PR, I'll be happy to merge it.
There are some solutions on elixir forum.