Make feed refresh request asynchronous
This commit is contained in:
parent
c37bed932f
commit
b63081392c
|
@ -10,7 +10,7 @@ defmodule Frenzy.UpdateFeeds do
|
|||
end
|
||||
|
||||
def refresh(pid, feed) do
|
||||
GenServer.call(pid, {:refresh, feed})
|
||||
GenServer.cast(pid, {:refresh, feed})
|
||||
end
|
||||
|
||||
def init(state) do
|
||||
|
@ -19,10 +19,9 @@ defmodule Frenzy.UpdateFeeds do
|
|||
{:ok, state}
|
||||
end
|
||||
|
||||
def handle_call({:refresh, feed}, _from, state) do
|
||||
def handle_cast({:refresh, feed}, state) do
|
||||
update_feed(feed)
|
||||
new_feed = Feed |> Repo.get(feed.id) |> Repo.preload(:items)
|
||||
{:reply, new_feed, state}
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
def handle_info(:update_feeds, state) do
|
||||
|
|
|
@ -110,7 +110,7 @@ defmodule FrenzyWeb.FeedController do
|
|||
|
||||
def refresh(conn, _params) do
|
||||
feed = conn.assigns[:feed]
|
||||
feed = Frenzy.UpdateFeeds.refresh(Frenzy.UpdateFeeds, feed)
|
||||
Frenzy.UpdateFeeds.refresh(Frenzy.UpdateFeeds, feed)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Refreshing feed. Wait a moment before reloading...")
|
||||
|
|
Loading…
Reference in New Issue