Skip to content

Commit 9671a04

Browse files
committed
Update /feeds on unread_entries
1 parent 8ca8a2e commit 9671a04

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/ex_rss_web/feed_live/index.ex

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ defmodule ExRssWeb.FeedLive.Index do
1111
%{"api_token" => api_token, "current_user" => current_user} = _session,
1212
socket
1313
) do
14+
ExRssWeb.Endpoint.subscribe("user:#{current_user.id}")
15+
1416
socket =
1517
socket
1618
|> assign(:current_user, current_user)
@@ -166,6 +168,10 @@ defmodule ExRssWeb.FeedLive.Index do
166168
end
167169
end
168170

171+
def handle_info(%{event: "unread_entries"}, socket) do
172+
{:noreply, assign_feeds(socket, reset: true)}
173+
end
174+
169175
def update_feed_position(feed_id, position, socket) do
170176
changeset =
171177
Repo.get!(User, socket.assigns.current_user.id)

0 commit comments

Comments
 (0)