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 {
7474 ...oc ( config ) . headers ( undefined ) ,
7575 } ,
7676 } ;
77- const axiosResponse = await axios ( axiosRequestConfig ) ;
77+
78+ const [ axiosResponse ] = await Promise . all ( [ axios ( axiosRequestConfig ) , HttpUtility . _delay ( ) ] ) ;
7879
7980 const { status, data, request } = axiosResponse ;
8081
@@ -154,4 +155,17 @@ export default class HttpUtility {
154155
155156 return model ;
156157 }
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+ }
157171}
You can’t perform that action at this time.
0 commit comments