Skip to content

Commit

Permalink
#10276 refresh quick actions and don't show spinner at all
Browse files Browse the repository at this point in the history
  • Loading branch information
siemiatj committed Dec 7, 2020
1 parent 593c22d commit e000568
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 10 additions & 5 deletions frontend/src/actions/ViewActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ export function deleteView(id, isModal) {

/**
* @method fetchDocumentPending
* @summary
* @summary request data for the document and set the pending flag to true
*
* @param {string} id - viewId
* @param {boolean} isModal
* @param {boolean} websocketRefresh - in case of data fetches caused by
* ws we won't set the pending flag to true
*/
function fetchDocumentPending(id, isModal) {
function fetchDocumentPending(id, isModal, websocketRefresh) {
return {
type: FETCH_DOCUMENT_PENDING,
payload: { id, isModal },
payload: { id, isModal, websocketRefresh },
};
}

Expand Down Expand Up @@ -317,7 +322,7 @@ export function fetchDocument({
websocketRefresh = false,
}) {
return (dispatch, getState) => {
dispatch(fetchDocumentPending(windowId, isModal));
dispatch(fetchDocumentPending(windowId, isModal, websocketRefresh));

return browseViewRequest({
windowId,
Expand Down Expand Up @@ -422,7 +427,7 @@ export function fetchDocument({
}

// get quickactions
if (viewId && shouldFetchQuickActions && !websocketRefresh) {
if (viewId && shouldFetchQuickActions) {
dispatch(
fetchQuickActions({
windowId,
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/reducers/viewHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@ export default function viewHandler(state = initialState, action) {
}

case FETCH_DOCUMENT_PENDING: {
const { id, isModal } = action.payload;
const { id, isModal, websocketRefresh } = action.payload;
const type = getViewType(isModal);
const view = getLocalView(state, id, isModal);
// if a websocket event caused this data fetch, we're not setting
// pending flag to true as in case of multiple refreshes in a short
// period of time it will cause the spinner to flicker
// https://github.com/metasfresh/me03/issues/6262#issuecomment-733527251
const pending = websocketRefresh ? false : true;

return {
...state,
Expand All @@ -170,7 +175,7 @@ export default function viewHandler(state = initialState, action) {
[`${id}`]: {
...view,
notFound: false,
pending: true,
pending,
error: null,
},
},
Expand Down

0 comments on commit e000568

Please sign in to comment.