Skip to content

Commit

Permalink
Websocket Frontend Notifications: specify duration (#382)
Browse files Browse the repository at this point in the history
allow backend to specify longer durations for frontend notifications via websockets
  • Loading branch information
Theodlz authored Mar 28, 2024
1 parent 5648054 commit 5fde2d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion static/js/MessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ class MessageHandler {
const notificationHandler = (actionType, payload, dispatch) => {
if (actionType === SHOW_NOTIFICATION) {
const { note, type } = payload;
dispatch(showNotification(note, type));
let { duration } = payload;
// if the duration is missing or invalid (negative or too large), use the default
if (!duration || duration <= 0 || duration >= 30000) {
duration = 3000;
}
dispatch(showNotification(note, type, duration));
}
};

Expand Down

0 comments on commit 5fde2d7

Please sign in to comment.