Skip to content

Commit

Permalink
#10276 suppress filters/quickactions refreshes when data request come…
Browse files Browse the repository at this point in the history
…s from a ws
  • Loading branch information
siemiatj committed Dec 7, 2020
1 parent 45d0b93 commit 242deb2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
51 changes: 29 additions & 22 deletions frontend/src/actions/ViewActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export function fetchDocument({
pageLength,
orderBy,
isModal = false,
websocketRefresh = false,
}) {
return (dispatch, getState) => {
dispatch(fetchDocumentPending(windowId, isModal));
Expand All @@ -327,8 +328,11 @@ export function fetchDocument({
})
.then((response) => {
// remove the old filter from the store
const entityRelatedId = getEntityRelatedId({ windowId, viewId });
dispatch(deleteFilter(entityRelatedId));
if (!websocketRefresh) {
const entityRelatedId = getEntityRelatedId({ windowId, viewId });
dispatch(deleteFilter(entityRelatedId));
}


dispatch(fetchDocumentSuccess(windowId, response.data, isModal));

Expand All @@ -345,26 +349,29 @@ export function fetchDocument({

const state = getState();
const view = getView(state, windowId, isModal);
const filterId = getEntityRelatedId({ windowId, viewId });
const activeFiltersCaptions = populateFiltersCaptions({
filterData: view.layout.filters,
filtersActive: response.data.filters,
});
const filtersActive = formatFilters({
filtersData: view.layout.filters,
filtersActive: response.data.filters,
});

dispatch(
createFilter({
filterId,
data: {
filterData: view.layout.filters, // set the proper layout for the filters
filtersActive,
activeFiltersCaptions,
},
})
);
if (!websocketRefresh) {
const filterId = getEntityRelatedId({ windowId, viewId });
const activeFiltersCaptions = populateFiltersCaptions({
filterData: view.layout.filters,
filtersActive: response.data.filters,
});
const filtersActive = formatFilters({
filtersData: view.layout.filters,
filtersActive: response.data.filters,
});

dispatch(
createFilter({
filterId,
data: {
filterData: view.layout.filters, // set the proper layout for the filters
filtersActive,
activeFiltersCaptions,
},
})
);
}

let shouldFetchQuickActions = true;
let viewProfileId = null;
Expand Down Expand Up @@ -416,7 +423,7 @@ export function fetchDocument({
}

// get quickactions
if (viewId && shouldFetchQuickActions) {
if (viewId && shouldFetchQuickActions && !websocketRefresh) {
dispatch(
fetchQuickActions({
windowId,
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ body{
.document-list-body {
display: flex;
flex-grow: 1;
position: relative;
/*flex-direction: column;*/
}

Expand Down Expand Up @@ -1006,7 +1007,8 @@ body{
border-radius: 3px;
display: inline-block;
position: absolute;
z-index: 4;
/* it has to come on top of the overlay */
z-index: 500;
left: 0;
top: 31px;
list-style: none;
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,9 @@ export default class DocumentList extends Component {
</div>
)}

{triggerSpinner && !inBackground && <Spinner iconSize={50} />}

{layout && (
<div className="document-list-body">
{triggerSpinner && !inBackground && <Spinner iconSize={50} />}
<div className="row table-context">
<Table
entity="documentView"
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/containers/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class DocumentListContainer extends Component {
this.fetchLayoutAndData();
this.renderedSuccessfuly = false;

this.debouncedRefresh = debounce(this.browseView, 500, { maxWait: 10000 });
this.debouncedRefresh = debounce(() => {
this.browseView(true);
}, 500, { maxWait: 10000 });
}

UNSAFE_componentWillMount() {
Expand Down Expand Up @@ -322,7 +324,7 @@ class DocumentListContainer extends Component {
* @method browseView
* @summary If viewId exists, than browse that view.
*/
browseView = () => {
browseView = (websocketRefresh) => {
const {
viewId,
page,
Expand All @@ -336,7 +338,7 @@ class DocumentListContainer extends Component {

// in case of redirect from a notification, first call will have viewId empty
if (viewId) {
this.getData(viewId, page, sort, locationSearchFilter).catch((err) => {
this.getData(viewId, page, sort, locationSearchFilter, websocketRefresh).catch((err) => {
if (err.response && err.response.status === 404) {
this.createNewView();
}
Expand Down Expand Up @@ -459,7 +461,7 @@ class DocumentListContainer extends Component {
* @method getData
* @summary Loads view/included tab data from REST endpoint
*/
getData = (id, page, sortingQuery, locationAreaSearch) => {
getData = (id, page, sortingQuery, locationAreaSearch, websocketRefresh) => {
const {
windowId,
updateUri,
Expand Down Expand Up @@ -490,6 +492,7 @@ class DocumentListContainer extends Component {
pageLength: this.pageLength,
orderBy: sortingQuery,
isModal,
websocketRefresh,
})
.then((response) => {
const result = response.result;
Expand Down

0 comments on commit 242deb2

Please sign in to comment.