From 71a35338d669805e8750c956e1c715e99804fa5d Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 18:08:32 +0200 Subject: [PATCH 1/8] Fix empty failure response --- src/api/wishes.php | 2 ++ src/api/wishlists.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/api/wishes.php b/src/api/wishes.php index 6d94ddce..7e589a8c 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -109,6 +109,8 @@ switch ($_SERVER['REQUEST_METHOD']) { WHERE `id` = ' . $_DELETE['wish_id'] . ' ;'); } + + $response['success'] = true; break; } diff --git a/src/api/wishlists.php b/src/api/wishlists.php index 79de19d3..bab0ff5a 100644 --- a/src/api/wishlists.php +++ b/src/api/wishlists.php @@ -110,6 +110,7 @@ switch ($_SERVER['REQUEST_METHOD']) { WHERE `id` = ' . $_DELETE['wishlistID'] . ' ;'); + $response['success'] = true; break; } From 4303efaf9ef21c6749e344ff645c27719d7b1653 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 18:13:58 +0200 Subject: [PATCH 2/8] Fix wish edit causing 404 --- src/pages/wish.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/wish.php b/src/pages/wish.php index ebd87a7c..d124bec4 100644 --- a/src/pages/wish.php +++ b/src/pages/wish.php @@ -35,7 +35,7 @@ if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) { $page->messages[] = Page::success(__('Wish successfully updated.'), __('Success')); } -if (!$userIsAuthenticated || !$wish->exists) { +if (!$wish->exists) { $page->errorDocument(404, $wish); } @@ -48,6 +48,10 @@ foreach ($wishlists as $wishlist) { } } +if (!$userIsAuthenticated) { + $page->errorDocument(404, $wish); +} + $page->header(); $page->bodyStart(); $page->navigation(); From 6ffdabd93b1ab01ca9555b4d1710397154529363 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 18:40:57 +0200 Subject: [PATCH 3/8] Fix wishlist and wish urls --- .htaccess | 2 +- src/assets/js/wishlists.js | 10 ++++++---- src/pages/wish.php | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.htaccess b/.htaccess index bed7f119..4bbb01b3 100644 --- a/.htaccess +++ b/.htaccess @@ -8,7 +8,7 @@ RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&id=$2 [QSA,L] # Wishlists - RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&wishlist=$2 [QSA,L] + RewriteRule ^([a-z\-]+)/(\d+)$ /?page=$1&id=$2 [QSA,L] # Wishlist RewriteRule ^wishlist/([a-z0-9]+)$ /?wishlist=$1 [QSA,L] diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js index 6edf5341..5ac7e952 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/wishlists.js @@ -17,8 +17,8 @@ $(function () { placeholder : text.wishlist_no_selection }) - if ($_GET.wishlist) { - element.dropdown('set selected', $_GET.wishlist); + if ($_GET.id) { + element.dropdown('set selected', $_GET.id); } else { if (wishlists[0]) { element.dropdown('set selected', wishlists[0].value); @@ -53,9 +53,11 @@ $(function () { $('.wishlist-delete').removeClass('disabled'); /** Update URL */ - urlParams.set('wishlist', wishlistValue); + urlParams.set('id', wishlistValue); - fetch('/src/api/url.php?url=' + btoa(urlParams.toString()), { + console.log(wishlistValue); + + fetch('/src/api/url.php?url=' + window.btoa(urlParams.toString()), { method: 'GET' }) .then(handleFetchError) diff --git a/src/pages/wish.php b/src/pages/wish.php index d124bec4..2460885f 100644 --- a/src/pages/wish.php +++ b/src/pages/wish.php @@ -56,7 +56,7 @@ $page->header(); $page->bodyStart(); $page->navigation(); -$referer = '/?page=wishlists&wishlist=' . $wish->wishlist; +$referer = '/?page=wishlists&id=' . $wish->wishlist; ?>
From bac40290d6c564214f5f3221dc9dfbe8c704eb57 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 19:03:32 +0200 Subject: [PATCH 4/8] Disable channel settings on PWA --- src/assets/js/profile.js | 18 +++++++++++++++++- src/pages/profile.php | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/assets/js/profile.js b/src/assets/js/profile.js index e9b06b3f..dbcedbe4 100644 --- a/src/assets/js/profile.js +++ b/src/assets/js/profile.js @@ -25,9 +25,25 @@ $(function() { } }); - $('.ui.dropdown').dropdown(); + $('.ui.dropdown.channel').dropdown(); $('.ui.dropdown.locale').dropdown({ sortSelect : 'natural', }); $('.ui.progress').progress(); + + var isPWA = window.matchMedia('(display-mode: standalone)').matches; + + if (isPWA) { + $('.ui.dropdown.channel').dropdown('set selected', 'stable'); + $('.ui.dropdown.channel').addClass('disabled'); + $('.ui.dropdown.channel').find('select').removeAttr('name'); + + if ('undefined' !== typeof CHANNELS) { + CHANNELS.forEach(channel => { + if (channel.host === location.host) { + $('.ui.dropdown.channel').dropdown('set selected', channel.branch); + } + }); + } + } }); diff --git a/src/pages/profile.php b/src/pages/profile.php index 1d0a069d..2344ca9f 100644 --- a/src/pages/profile.php +++ b/src/pages/profile.php @@ -260,10 +260,14 @@ $page->navigation(); + +
- From 05f9aed12a97ed43f70f2f2bf6900d34c6b9ae55 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 19:14:34 +0200 Subject: [PATCH 5/8] Downgrade to v0.5.0 --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index df5a7089..69d109dd 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ * @author Jay Trees */ -define('VERSION', '0.6.0'); +define('VERSION', '0.5.0'); define('ROOT', __DIR__); define('DEFAULT_LOCALE', 'en_GB'); From 0ca354cfc3ad0d034cc9777e8ba454c26357bfac Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 20:10:25 +0200 Subject: [PATCH 6/8] Fix wishlist change on wish add --- src/assets/js/default.js | 4 ++-- src/assets/js/wishlists.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/assets/js/default.js b/src/assets/js/default.js index ffe81db8..b3e1b77b 100644 --- a/src/assets/js/default.js +++ b/src/assets/js/default.js @@ -40,8 +40,8 @@ $(function() { placeholder: text.wishlist_no_selection }) - if ($_GET.wishlist) { - element.dropdown('set selected', $_GET.wishlist); + if ($_GET.id) { + element.dropdown('set selected', $_GET.id); } else { if (response.results[0]) { element.dropdown('set selected', response.results[0].value); diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js index 5ac7e952..bfbfbd02 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/wishlists.js @@ -43,7 +43,7 @@ $(function () { progress.addClass('indeterminate'); if (wishlistValue) { - $_GET.wishlist = wishlistValue; + $_GET.id = wishlistValue; $('.wishlist-share').attr('href', '/?wishlist=' + wishlists[wishlistIndex].hash); @@ -274,7 +274,7 @@ $(function () { wishlists.dropdown('clear'); - urlParams.delete('wishlist'); + urlParams.delete('id'); $('body').toast({ message:text.toast_wishlist_delete }); @@ -426,7 +426,7 @@ $(function () { .then(function(response) { modalWishlistCreate.modal('hide'); - urlParams.set('wishlist', response.data.lastInsertId); + urlParams.set('id', response.data.lastInsertId); $('body').toast({ message: text.toast_wish_create }); From 1a6e6ff31f75c71cf32bc5f49b27b0ca2b3dc87a Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 20:10:34 +0200 Subject: [PATCH 7/8] Improve PWA detection --- src/assets/js/profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/js/profile.js b/src/assets/js/profile.js index dbcedbe4..c31b2e2a 100644 --- a/src/assets/js/profile.js +++ b/src/assets/js/profile.js @@ -31,7 +31,7 @@ $(function() { }); $('.ui.progress').progress(); - var isPWA = window.matchMedia('(display-mode: standalone)').matches; + var isPWA = navigator.standalone || window.matchMedia('(display-mode: standalone)').matches; if (isPWA) { $('.ui.dropdown.channel').dropdown('set selected', 'stable'); From d817f6db8ffd7db2df141ebf531edc4cb88bbabe Mon Sep 17 00:00:00 2001 From: grandeljay Date: Thu, 7 Apr 2022 20:36:49 +0200 Subject: [PATCH 8/8] Fix missing success responses --- src/api/wishes.php | 4 ++++ src/api/wishlists.php | 1 + 2 files changed, 5 insertions(+) diff --git a/src/api/wishes.php b/src/api/wishes.php index 7e589a8c..74424633 100644 --- a/src/api/wishes.php +++ b/src/api/wishes.php @@ -90,6 +90,8 @@ switch ($_SERVER['REQUEST_METHOD']) { SET `status` = "' . $_PUT['wish_status'] . '" WHERE `id` = ' . $_PUT['wish_id'] . ' ;'); + + $response['success'] = true; } elseif (isset($_PUT['wish_url_current'], $_PUT['wish_url_proposed'])) { /** * Update Wish URL @@ -98,6 +100,8 @@ switch ($_SERVER['REQUEST_METHOD']) { SET `url` = "' . $_PUT['wish_url_proposed'] . '" WHERE `url` = "' . $_PUT['wish_url_current'] . '" ;'); + + $response['success'] = true; } break; diff --git a/src/api/wishlists.php b/src/api/wishlists.php index bab0ff5a..e723789a 100644 --- a/src/api/wishlists.php +++ b/src/api/wishlists.php @@ -101,6 +101,7 @@ switch ($_SERVER['REQUEST_METHOD']) { WHERE `id` = ' . $_PUT['wishlist_id'] . ' ;'); + $response['success'] = true; break; case 'DELETE':