Fix current page changing when marking items as read

This commit is contained in:
Shadowfacts 2021-09-15 10:38:46 -04:00
parent 3b12f62379
commit d62d12262d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
4 changed files with 6 additions and 4 deletions

View File

@ -41,12 +41,12 @@
<td class="py-0 align-middle"> <td class="py-0 align-middle">
<%= if item.read do %> <%= if item.read do %>
<%= form_tag Routes.item_path(@conn, :unread, item.id), method: :post do %> <%= form_tag Routes.item_path(@conn, :unread, item.id), method: :post do %>
<input type="hidden" name="redirect" value="<%=Routes.feed_path(@conn, :show, @feed.id) %>"> <input type="hidden" name="redirect" value="<%= current_path(@conn) %>">
<%= submit "Unread", class: "btn btn-sm btn-secondary" %> <%= submit "Unread", class: "btn btn-sm btn-secondary" %>
<% end %> <% end %>
<% else %> <% else %>
<%= form_tag Routes.item_path(@conn, :read, item.id), method: :post do %> <%= form_tag Routes.item_path(@conn, :read, item.id), method: :post do %>
<input type="hidden" name="redirect" value="<%=Routes.feed_path(@conn, :show, @feed.id) %>"> <input type="hidden" name="redirect" value="<%= current_path(@conn) %>">
<%= submit "Read", class: "btn btn-sm btn-secondary" %> <%= submit "Read", class: "btn btn-sm btn-secondary" %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -32,12 +32,12 @@
<td class="py-0 align-middle"> <td class="py-0 align-middle">
<%= if item.read do %> <%= if item.read do %>
<%= form_tag Routes.item_path(@conn, :unread, item.id), method: :post do %> <%= form_tag Routes.item_path(@conn, :unread, item.id), method: :post do %>
<input type="hidden" name="redirect" value="<%=Routes.group_path(@conn, :read, @group.id) %>"> <input type="hidden" name="redirect" value="<%= current_path(@conn) %>">
<%= submit "Unread", class: "btn btn-sm btn-secondary" %> <%= submit "Unread", class: "btn btn-sm btn-secondary" %>
<% end %> <% end %>
<% else %> <% else %>
<%= form_tag Routes.item_path(@conn, :read, item.id), method: :post do %> <%= form_tag Routes.item_path(@conn, :read, item.id), method: :post do %>
<input type="hidden" name="redirect" value="<%=Routes.group_path(@conn, :read, @group.id) %>"> <input type="hidden" name="redirect" value="<%= current_path(@conn) %>">
<%= submit "Read", class: "btn btn-sm btn-secondary" %> <%= submit "Read", class: "btn btn-sm btn-secondary" %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,6 +1,7 @@
defmodule FrenzyWeb.FeedView do defmodule FrenzyWeb.FeedView do
use FrenzyWeb, :view use FrenzyWeb, :view
alias Frenzy.Feed alias Frenzy.Feed
import Phoenix.Controller, only: [current_path: 1]
@spec feed_site_url(feed :: Feed.t()) :: String.t() @spec feed_site_url(feed :: Feed.t()) :: String.t()
def feed_site_url(%Feed{site_url: site_url}) when is_binary(site_url) do def feed_site_url(%Feed{site_url: site_url}) when is_binary(site_url) do

View File

@ -1,5 +1,6 @@
defmodule FrenzyWeb.GroupView do defmodule FrenzyWeb.GroupView do
use FrenzyWeb, :view use FrenzyWeb, :view
import Phoenix.Controller, only: [current_path: 1]
def title(:index, _) do def title(:index, _) do
"Groups" "Groups"