Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1090 from metasfresh/dev-1084
Browse files Browse the repository at this point in the history
Handle websocket document stale event #1084
  • Loading branch information
teosarca committed Jul 28, 2017
2 parents c70e92c + 14e66e0 commit 1e8de16
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/actions/WindowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,20 @@ export function patch(
}
}

export function fireUpdateData(entity, windowType, id, tabId, rowId, isModal,
isAdvanced){

return dispatch => {
getData(
entity, windowType, id, tabId, rowId, null, null, isAdvanced
).then(response => {
dispatch(mapDataToState(
response.data, isModal, rowId, id, windowType, isAdvanced
));
});
}
}

function updateData(doc, scope){
return dispatch => {
Object.keys(doc).map(key => {
Expand Down
13 changes: 11 additions & 2 deletions src/containers/MasterWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
addRowData,
sortTab,
connectWS,
disconnectWS
disconnectWS,
fireUpdateData
} from '../actions/WindowActions';

import {
Expand Down Expand Up @@ -49,8 +50,16 @@ class MasterWindow extends Component {

if(prevProps.master.websocket !== master.websocket && master.websocket){
connectWS.call(this, master.websocket, msg => {
const {includedTabsInfo} = msg;
const {includedTabsInfo, stale} = msg;
const {master} = this.props;

if(stale){
dispatch(
fireUpdateData('window', params.windowType, params.docId, null, null, null, null )
);

}

includedTabsInfo && Object.keys(includedTabsInfo).map(tabId => {
const tabLayout = master.layout.tabs && master.layout.tabs.filter(tab =>
tab.tabId === tabId
Expand Down

0 comments on commit 1e8de16

Please sign in to comment.