From 07e38ced915ae7e32f8326267a66b29adc606898 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Mon, 13 Jun 2022 08:50:35 +0200 Subject: [PATCH] Fix success message on failure --- src/api/wishes.php | 8 ++++++-- src/assets/js/wishlists.js | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/api/wishes.php b/src/api/wishes.php index f2fc198e..90eb8d84 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -9,7 +9,9 @@ namespace wishthis; $api = true; -$response = array(); +$response = array( + 'success' => false, +); ob_start(); @@ -83,7 +85,8 @@ switch ($_SERVER['REQUEST_METHOD']) { $wish_image = is_null($info->image) ? 'NULL' : "' . $info->image . '"; $response = array( - 'info' => $info, + 'info' => $info, + 'success' => true, ); } @@ -137,6 +140,7 @@ switch ($_SERVER['REQUEST_METHOD']) { $response['data'] = array( 'lastInsertId' => $database->lastInsertId(), + 'success' => true, ); } break; diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js index bc42a3b7..d8ca799c 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/wishlists.js @@ -587,6 +587,10 @@ $(function () { .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { + if (true !== response.success) { + return; + } + $('body').toast({ message: text.toast_wish_update }); wishlistsRefresh(); @@ -614,6 +618,10 @@ $(function () { .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { + if (true !== response.success) { + return; + } + $('body').toast({ message: text.toast_wish_update }); wishlistsRefresh();