File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,8 @@ export default class HttpUtility {
74
74
...oc ( config ) . headers ( undefined ) ,
75
75
} ,
76
76
} ;
77
- const axiosResponse = await axios ( axiosRequestConfig ) ;
77
+
78
+ const [ axiosResponse ] = await Promise . all ( [ axios ( axiosRequestConfig ) , HttpUtility . _delay ( ) ] ) ;
78
79
79
80
const { status, data, request } = axiosResponse ;
80
81
@@ -154,4 +155,17 @@ export default class HttpUtility {
154
155
155
156
return model ;
156
157
}
158
+
159
+ /**
160
+ * We want to show the loading indicator to the user but sometimes the api
161
+ * request finished too quickly. This makes sure there the loading indicator is
162
+ * visual for at least a given time.
163
+ *
164
+ * @param duration
165
+ * @returns {Promise<unknown> }
166
+ * @private
167
+ */
168
+ static _delay ( duration = 250 ) {
169
+ return new Promise ( ( resolve ) => setTimeout ( resolve , 250 ) ) ;
170
+ }
157
171
}
You can’t perform that action at this time.
0 commit comments