From 7620d8d8cdcbbf7887c51dd596505e198bae3480 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Fri, 14 Oct 2022 02:36:12 -0700 Subject: [PATCH] show the error toast on errors, not the success toast --- files/assets/js/core.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 6e6461053d..2003e68bd8 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -46,7 +46,7 @@ function postToastLoad(xhr, className, extraActionsOnSuccess, extraActionsOnErro } else { let message = data && data["error"] ? data["error"] : "Error, please try again later" if (data && data["details"]) message = data["details"]; - showToast(true, message); + showToast(false, message); if (extraActionsOnError) extraActionsOnError(xhr); } } @@ -62,8 +62,13 @@ function postPostToastNonShopActions(t, url, button1, button2, className) { } } +/* temporary compatability function. js styling wants us to use thisCase so any new things should use that */ function post_toast(t, url, button1, button2, classname, extra_actions, extra_actions_error) { - prePostToastNonShopActions(t, url, button1, button2, classname) + postToast(t, url, button1, button2, classname, extra_actions, extra_actions_error); +} + +function postToast(t, url, button1, button2, className, extraActions, extraActionsError) { + prePostToastNonShopActions(t, url, button1, button2, className) const xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.setRequestHeader('xhr', 'xhr'); @@ -71,8 +76,8 @@ function post_toast(t, url, button1, button2, classname, extra_actions, extra_ac form.append("formkey", formkey()); xhr.onload = function() { - postToastLoad(xhr, classname, extra_actions, extra_actions_error) - postPostToastNonShopActions(t, url, button1, button2, classname) + postToastLoad(xhr, className, extraActions, extraActionsError) + postPostToastNonShopActions(t, url, button1, button2, className) }; xhr.send(form); }