Revision b8c9069d
Added by matan werbner about 7 years ago
config/webpack.config.js | ||
---|---|---|
allChunks: true
|
||
}),
|
||
new webpack.DefinePlugin({
|
||
'process.env': { NODE_ENV: JSON.stringify(production ? 'production' : 'development') }
|
||
'process.env': {
|
||
NODE_ENV: JSON.stringify(production ? 'production' : 'development'),
|
||
NOTIFICATIONS_POLLING: process.env.NOTIFICATIONS_POLLING
|
||
}
|
||
})
|
||
]
|
||
};
|
||
... | ... | |
compressor: { warnings: false },
|
||
sourceMap: false
|
||
}),
|
||
|
||
|
||
new webpack.optimize.DedupePlugin(),
|
||
new webpack.optimize.OccurenceOrderPlugin(),
|
||
new CompressionPlugin()
|
webpack/assets/javascripts/react_app/redux/actions/notifications/index.js | ||
---|---|---|
notificationsDrawer as sessionStorage
|
||
} from '../../../common/sessionStorage';
|
||
import API from '../../../API';
|
||
const getNotificationsInterval = 10000;
|
||
import { isNil } from 'lodash';
|
||
const defaultNotificationsPollingInterval = 10000;
|
||
const notificationsInterval = isNil(process.env.NOTIFICATIONS_POLLING) ?
|
||
defaultNotificationsPollingInterval :
|
||
process.env.NOTIFICATIONS_POLLING;
|
||
|
||
export const getNotifications = url => dispatch => {
|
||
new Promise((resolve, reject) => {
|
||
... | ... | |
document.visibilityState === 'visible' ||
|
||
document.visibilityState === 'prerender'
|
||
) {
|
||
API.get(url).then(response => {
|
||
dispatch({
|
||
type: NOTIFICATIONS_GET_NOTIFICATIONS,
|
||
payload: {
|
||
notifications: response.notifications
|
||
}
|
||
});
|
||
resolve();
|
||
}, () => reject());
|
||
API.get(url).then(
|
||
response => {
|
||
dispatch({
|
||
type: NOTIFICATIONS_GET_NOTIFICATIONS,
|
||
payload: {
|
||
notifications: response.notifications
|
||
}
|
||
});
|
||
resolve();
|
||
},
|
||
() => reject()
|
||
);
|
||
} else {
|
||
resolve();
|
||
}
|
||
return null;
|
||
}).then(
|
||
() => {
|
||
setTimeout(
|
||
() => dispatch(getNotifications(url)),
|
||
getNotificationsInterval
|
||
);
|
||
if (notificationsInterval) {
|
||
setTimeout(
|
||
() => dispatch(getNotifications(url)),
|
||
notificationsInterval
|
||
);
|
||
}
|
||
},
|
||
// error handling
|
||
() => {}
|
Also available in: Unified diff
Fixes #18438 - control notifications polling