Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader Lists: improve error notices #47444

Merged
merged 1 commit into from Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/state/data-layer/wpcom/read/lists/delete/index.js
Expand Up @@ -35,7 +35,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/delete/index.js', {
} ),
];
},
onError: () => errorNotice( translate( 'There was a problem deleting the list.' ) ),
onError: () => errorNotice( translate( 'Unable to delete list.' ) ),
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
} ),
],
} );
Expand Up @@ -29,7 +29,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/feeds/delete/index.js', {
onSuccess: successNotice( translate( 'Feed removed from list successfully.' ), {
duration: DEFAULT_NOTICE_DURATION,
} ),
onError: () => errorNotice( translate( 'Unable to remove feed from list' ) ),
onError: () => errorNotice( translate( 'Unable to remove feed from list.' ) ),
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
} ),
],
} );
8 changes: 2 additions & 6 deletions client/state/data-layer/wpcom/read/lists/feeds/new/index.js
Expand Up @@ -45,12 +45,8 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/feeds/new/index.js', {
} ),
];
},
onError: ( action, error ) => {
return errorNotice(
translate( 'Could not add feed to list: %(message)s', {
args: { message: error?.message },
} )
);
onError: () => {
return errorNotice( translate( 'Unable to add feed to list.' ) );
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
},
} ),
],
Expand Down
19 changes: 8 additions & 11 deletions client/state/data-layer/wpcom/read/lists/index.js
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { translate } from 'i18n-calypso';
import { noop } from 'lodash';

/**
* Internal dependencies
Expand Down Expand Up @@ -57,11 +58,10 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/index.js', {
} ),
];
}
// NOTE: Add better handling for unexpected response format here.
jsnmoon marked this conversation as resolved.
Show resolved Hide resolved
errorNotice( translate( 'List could not be created, please try again later.' ) );
errorNotice( translate( 'Unable to create new list.' ) );
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
},
onError: ( action, error ) => [
errorNotice( String( error ) ),
errorNotice( translate( 'Unable to create new list.' ) ),
handleReaderListRequestFailure( error ),
],
} ),
Expand All @@ -81,7 +81,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/index.js', {
onSuccess: ( action, { list } ) => {
return receiveFollowList( list );
},
onError: ( action, error ) => [ errorNotice( String( error ) ) ],
onError: () => [ errorNotice( translate( 'Unable to follow list.' ) ) ],
} ),
],
[ READER_LIST_REQUEST ]: [
Expand All @@ -96,10 +96,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/index.js', {
action
),
onSuccess: ( action, { list } ) => receiveReaderList( { list } ),
onError: ( action, error ) => [
errorNotice( String( error ) ),
handleReaderListRequestFailure( error ),
],
onError: ( action, error ) => [ handleReaderListRequestFailure( error ) ],
} ),
],
[ READER_LIST_UNFOLLOW ]: [
Expand All @@ -117,7 +114,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/index.js', {
onSuccess: ( action, { list } ) => {
return receiveUnfollowList( list );
},
onError: ( action, error ) => [ errorNotice( String( error ) ) ],
onError: () => [ errorNotice( translate( 'Unable to unfollow list.' ) ) ],
} ),
],
[ READER_LIST_UPDATE ]: [
Expand All @@ -140,7 +137,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/index.js', {
} ),
],
onError: ( action, error ) => [
errorNotice( String( error ) ),
errorNotice( translate( 'Unable to update list.' ) ),
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
handleUpdateListDetailsError( error, action.list ),
],
} ),
Expand All @@ -157,7 +154,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/index.js', {
action
),
onSuccess: ( action, apiResponse ) => receiveLists( apiResponse?.lists ),
onError: ( action, error ) => errorNotice( String( error ) ),
onError: () => noop,
} ),
],
} );
8 changes: 6 additions & 2 deletions client/state/data-layer/wpcom/read/lists/items/index.js
@@ -1,9 +1,13 @@
/**
* External dependencies
*/
import { noop } from 'lodash';

/**
* Internal dependencies
*/
import { http } from 'calypso/state/data-layer/wpcom-http/actions';
import { dispatchRequest } from 'calypso/state/data-layer/wpcom-http/utils';
import { errorNotice } from 'calypso/state/notices/actions';
import { READER_LIST_ITEMS_REQUEST } from 'calypso/state/reader/action-types';
import { receiveReaderListItems } from 'calypso/state/reader/lists/actions';
import { registerHandlers } from 'calypso/state/data-layer/handler-registry';
Expand All @@ -23,7 +27,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/items/index.js', {
),
onSuccess: ( action, apiResponse ) =>
receiveReaderListItems( apiResponse.list_ID, apiResponse.items ),
onError: ( action, error ) => errorNotice( String( error ) ),
onError: () => noop,
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
} ),
],
} );
Expand Up @@ -29,7 +29,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/tags/delete/index.js', {
onSuccess: successNotice( translate( 'Tag removed from list successfully.' ), {
duration: DEFAULT_NOTICE_DURATION,
} ),
onError: () => errorNotice( translate( 'Unable to remove tag from list' ) ),
onError: () => errorNotice( translate( 'Unable to remove tag from list.' ) ),
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
} ),
],
} );
2 changes: 1 addition & 1 deletion client/state/data-layer/wpcom/read/lists/tags/new/index.js
Expand Up @@ -42,7 +42,7 @@ registerHandlers( 'state/data-layer/wpcom/read/lists/tags/new/index.js', {
} ),
];
},
onError: ( action, error ) => errorNotice( String( error ) ),
onError: () => errorNotice( translate( 'Unable to add tag to list.' ) ),
} ),
],
} );