Exception when trying to access the import/export/backup tray when current Page is not yet in db
yulolimum opened this issue · 3 comments
yulolimum commented
If you have a Page that hasn't yet been registered in the database, when you access the import/export tray you get an exception. We need another function to handle when the page is nil
.
def backups(page_slug) when is_binary(page_slug) do
page = page(page_slug)
backups(page.id)
end
def backups(page_id) when is_integer(page_id) do
repo().all(
from b in Backup,
where: b.page_id == ^page_id,
order_by: [desc: b.page_revision]
)
end
yulolimum commented
Some context: when you access that specific tray, we make a request to get all revisions for this specific page. We make this request every single time you hit that button. It is so that you don't have to refresh the page to see a list of updated revisions after you publish some changes.
yulolimum commented
We can just return empty array if page is nil.