From 9c1e6f3b278deea03c7f041a44e44006ca3d09b0 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Fri, 7 Feb 2025 12:07:12 +0100
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Remove=20error=20handling?=
=?UTF-8?q?=20from=20persist=20actions?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/js/data/_example/actions.js | 16 +++++-----------
.../resources/js/data/common/actions-thunk.js | 4 +---
.../js/data/pay-later-messaging/actions.js | 16 +++++-----------
.../resources/js/data/payment/actions.js | 16 +++++-----------
.../resources/js/data/settings/actions.js | 16 +++++-----------
.../resources/js/data/styling/actions.js | 16 +++++-----------
.../resources/js/data/todos/actions.js | 3 +--
7 files changed, 27 insertions(+), 60 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/data/_example/actions.js b/modules/ppcp-settings/resources/js/data/_example/actions.js
index b2e805ae5..f9cd9a556 100644
--- a/modules/ppcp-settings/resources/js/data/_example/actions.js
+++ b/modules/ppcp-settings/resources/js/data/_example/actions.js
@@ -75,16 +75,10 @@ export const setIsReady = ( isReady ) => setTransient( 'isReady', isReady );
*/
export function persist() {
return async ( { select } ) => {
- const data = select.persistentData();
-
- try {
- await apiFetch( {
- path: REST_PERSIST_PATH,
- method: 'POST',
- data,
- } );
- } catch ( e ) {
- console.error( 'Error saving progress.', e );
- }
+ await apiFetch( {
+ path: REST_PERSIST_PATH,
+ method: 'POST',
+ data: select.persistentData(),
+ } );
};
}
diff --git a/modules/ppcp-settings/resources/js/data/common/actions-thunk.js b/modules/ppcp-settings/resources/js/data/common/actions-thunk.js
index e12537aa8..0de08f245 100644
--- a/modules/ppcp-settings/resources/js/data/common/actions-thunk.js
+++ b/modules/ppcp-settings/resources/js/data/common/actions-thunk.js
@@ -19,12 +19,10 @@ import {
*/
export function persist() {
return async ( { select } ) => {
- const data = select.persistentData();
-
await apiFetch( {
path: REST_PERSIST_PATH,
method: 'POST',
- data,
+ data: select.persistentData(),
} );
};
}
diff --git a/modules/ppcp-settings/resources/js/data/pay-later-messaging/actions.js b/modules/ppcp-settings/resources/js/data/pay-later-messaging/actions.js
index b2e805ae5..f9cd9a556 100644
--- a/modules/ppcp-settings/resources/js/data/pay-later-messaging/actions.js
+++ b/modules/ppcp-settings/resources/js/data/pay-later-messaging/actions.js
@@ -75,16 +75,10 @@ export const setIsReady = ( isReady ) => setTransient( 'isReady', isReady );
*/
export function persist() {
return async ( { select } ) => {
- const data = select.persistentData();
-
- try {
- await apiFetch( {
- path: REST_PERSIST_PATH,
- method: 'POST',
- data,
- } );
- } catch ( e ) {
- console.error( 'Error saving progress.', e );
- }
+ await apiFetch( {
+ path: REST_PERSIST_PATH,
+ method: 'POST',
+ data: select.persistentData(),
+ } );
};
}
diff --git a/modules/ppcp-settings/resources/js/data/payment/actions.js b/modules/ppcp-settings/resources/js/data/payment/actions.js
index c412119d8..1107d5bfb 100644
--- a/modules/ppcp-settings/resources/js/data/payment/actions.js
+++ b/modules/ppcp-settings/resources/js/data/payment/actions.js
@@ -87,16 +87,10 @@ export const changePaymentSettings = ( id, props ) => ( {
*/
export function persist() {
return async ( { select } ) => {
- const data = select.persistentData();
-
- try {
- await apiFetch( {
- path: REST_PERSIST_PATH,
- method: 'POST',
- data,
- } );
- } catch ( e ) {
- console.error( 'Error saving progress.', e );
- }
+ await apiFetch( {
+ path: REST_PERSIST_PATH,
+ method: 'POST',
+ data: select.persistentData(),
+ } );
};
}
diff --git a/modules/ppcp-settings/resources/js/data/settings/actions.js b/modules/ppcp-settings/resources/js/data/settings/actions.js
index 9a5ac0a7c..6633516bb 100644
--- a/modules/ppcp-settings/resources/js/data/settings/actions.js
+++ b/modules/ppcp-settings/resources/js/data/settings/actions.js
@@ -77,16 +77,10 @@ export const setIsReady = ( isReady ) => setTransient( 'isReady', isReady );
*/
export function persist() {
return async ( { select } ) => {
- const data = select.persistentData();
-
- try {
- await apiFetch( {
- path: REST_PERSIST_PATH,
- method: 'POST',
- data,
- } );
- } catch ( e ) {
- console.error( 'Error saving progress.', e );
- }
+ await apiFetch( {
+ path: REST_PERSIST_PATH,
+ method: 'POST',
+ data: select.persistentData(),
+ } );
};
}
diff --git a/modules/ppcp-settings/resources/js/data/styling/actions.js b/modules/ppcp-settings/resources/js/data/styling/actions.js
index 48c248c2b..e655e7424 100644
--- a/modules/ppcp-settings/resources/js/data/styling/actions.js
+++ b/modules/ppcp-settings/resources/js/data/styling/actions.js
@@ -75,16 +75,10 @@ export const setIsReady = ( state ) => setTransient( 'isReady', state );
*/
export function persist() {
return async ( { select } ) => {
- const data = select.persistentData();
-
- try {
- await apiFetch( {
- path: REST_PERSIST_PATH,
- method: 'POST',
- data,
- } );
- } catch ( e ) {
- console.error( 'Error saving progress.', e );
- }
+ await apiFetch( {
+ path: REST_PERSIST_PATH,
+ method: 'POST',
+ data: select.persistentData(),
+ } );
};
}
diff --git a/modules/ppcp-settings/resources/js/data/todos/actions.js b/modules/ppcp-settings/resources/js/data/todos/actions.js
index ca14edc89..41ac372cd 100644
--- a/modules/ppcp-settings/resources/js/data/todos/actions.js
+++ b/modules/ppcp-settings/resources/js/data/todos/actions.js
@@ -48,11 +48,10 @@ export function fetchTodos() {
export function persist() {
return async ( { select } ) => {
- const data = await select.persistentData();
return await apiFetch( {
path: REST_PERSIST_PATH,
method: 'POST',
- data,
+ data: select.persistentData(),
} );
};
}