mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-16 05:06:32 +00:00
forceReload prevents ajax submission
...instead of weird hacky workarounds forcing refreshes later.
This commit is contained in:
parent
b91915d316
commit
5b67226571
4 changed files with 1 additions and 15 deletions
|
@ -74,7 +74,7 @@ let StatusCache = new class {
|
||||||
|
|
||||||
// This allows the form to submit in the old fashioned way if there's a problem
|
// This allows the form to submit in the old fashioned way if there's a problem
|
||||||
|
|
||||||
if (!trigger || !form) {
|
if (!trigger || !form || response.headers.get("forceReload")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +90,6 @@ let StatusCache = new class {
|
||||||
trigger.removeAttribute('disabled');
|
trigger.removeAttribute('disabled');
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.headers.get("forceReload")) {
|
|
||||||
BookWyrm.addRemoveClass(form, 'is-processing', true);
|
|
||||||
trigger.setAttribute('disabled', null);
|
|
||||||
|
|
||||||
return location.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
|
|
|
@ -102,8 +102,6 @@ class ReadingStatus(View):
|
||||||
!= desired_shelf.identifier
|
!= desired_shelf.identifier
|
||||||
):
|
):
|
||||||
return unshelve(request, referer=referer, book_id=book_id)
|
return unshelve(request, referer=referer, book_id=book_id)
|
||||||
# don't try to unshelve a read status shelf: it has already been deleted.
|
|
||||||
return HttpResponse(headers={"forceReload": "true"})
|
|
||||||
|
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
|
@ -101,6 +101,4 @@ def unshelve(request, referer=None, book_id=False):
|
||||||
)
|
)
|
||||||
shelf_book.raise_not_deletable(request.user)
|
shelf_book.raise_not_deletable(request.user)
|
||||||
shelf_book.delete()
|
shelf_book.delete()
|
||||||
if bool(referer):
|
|
||||||
return HttpResponse(headers={"forceReload": "true"})
|
|
||||||
return redirect(request.headers.get("Referer", "/"))
|
return redirect(request.headers.get("Referer", "/"))
|
||||||
|
|
|
@ -125,10 +125,6 @@ class CreateStatus(View):
|
||||||
except Http404:
|
except Http404:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# force page reload if this was triggered from 'move' button
|
|
||||||
if bool(request.POST.get("shelf")):
|
|
||||||
return HttpResponse(headers={"forceReload": "true"})
|
|
||||||
|
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
Loading…
Reference in a new issue