File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
packages/compass-data-modeling/src/provider Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ export const DataModelStorageServiceProvider: React.FunctionComponent<{
4848 return {
4949 ...serviceState ,
5050 async save ( toSave : MongoDBDataModelDescription ) {
51+ const saved = await storageRef . current . save ( toSave ) ;
52+ // If save fails in storage, we don't want to update the state
53+ // to avoid showing the item in the list.
54+ if ( ! saved ) {
55+ return false ;
56+ }
5157 setServiceState ( ( prevState ) => {
5258 const itemIdx = prevState . items . findIndex ( ( item ) => {
5359 return item . id === toSave . id ;
@@ -62,9 +68,15 @@ export const DataModelStorageServiceProvider: React.FunctionComponent<{
6268 items : [ ...prevState . items ] ,
6369 } ;
6470 } ) ;
65- return storageRef . current . save ( toSave ) ;
71+ return true ;
6672 } ,
6773 async delete ( id : MongoDBDataModelDescription [ 'id' ] ) {
74+ const deleted = await storageRef . current . delete ( id ) ;
75+ // If delete fails in storage, we don't want to update the state
76+ // to avoid showing the item in the list.
77+ if ( ! deleted ) {
78+ return false ;
79+ }
6880 setServiceState ( ( prevState ) => {
6981 return {
7082 ...prevState ,
@@ -73,7 +85,7 @@ export const DataModelStorageServiceProvider: React.FunctionComponent<{
7385 } ) ,
7486 } ;
7587 } ) ;
76- return storageRef . current . delete ( id ) ;
88+ return true ;
7789 } ,
7890 async loadAll ( ) {
7991 setServiceState ( ( prevState ) => {
You can’t perform that action at this time.
0 commit comments