Fix pagination breaking on tombstoned items

This commit is contained in:
Shadowfacts 2020-06-01 22:58:27 -04:00
parent 4e79a1fe19
commit 28a35b8241
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 12 additions and 4 deletions

View File

@ -43,7 +43,10 @@ defmodule FrenzyWeb.FeedController do
prev_page_path =
if !is_nil(first_item) &&
Repo.exists?(from i in Item, where: i.date > ^first_item.date and i.feed_id == ^id) do
Repo.exists?(
from i in Item,
where: not i.tombstone and i.date > ^first_item.date and i.feed_id == ^id
) do
current_path(conn, %{after: first_item.id})
else
nil
@ -51,7 +54,10 @@ defmodule FrenzyWeb.FeedController do
next_page_path =
if !is_nil(last_item) &&
Repo.exists?(from i in Item, where: i.date < ^last_item.date and i.feed_id == ^id) do
Repo.exists?(
from i in Item,
where: not i.tombstone and i.date < ^last_item.date and i.feed_id == ^id
) do
current_path(conn, %{before: last_item.id})
else
nil

View File

@ -118,7 +118,8 @@ defmodule FrenzyWeb.GroupController do
prev_page_path =
if !is_nil(first_item) &&
Repo.exists?(
from i in Item, where: i.date > ^first_item.date and i.feed_id in ^feed_ids
from i in Item,
where: not i.tombstone and i.date > ^first_item.date and i.feed_id in ^feed_ids
) do
current_path(conn, %{after: first_item.id})
else
@ -128,7 +129,8 @@ defmodule FrenzyWeb.GroupController do
next_page_path =
if !is_nil(last_item) &&
Repo.exists?(
from i in Item, where: i.date < ^last_item.date and i.feed_id in ^feed_ids
from i in Item,
where: not i.tombstone and i.date < ^last_item.date and i.feed_id in ^feed_ids
) do
current_path(conn, %{before: last_item.id})
else