Browse Source

Merge pull request #129 from SuperNETorg/toaster-auto-close-param

Toaster - add an auto close param (true by default)
all-modes
pbca26 8 years ago
committed by GitHub
parent
commit
70c231de80
  1. 3
      react/src/actions/actionCreators.js
  2. 7
      react/src/components/toaster/toaster-item.js
  3. 4
      react/src/components/toaster/toaster.js

3
react/src/actions/actionCreators.js

@ -190,13 +190,14 @@ export function toggleSendReceiveCoinFormsState() {
}
}
export function triggerToaster(display, message, title, _type) {
export function triggerToaster(display, message, title, _type, autoClose = true) {
return {
type: ADD_TOASTER_MESSAGE,
display,
message,
title,
_type,
autoClose
}
}

7
react/src/components/toaster/toaster-item.js

@ -16,7 +16,8 @@ class ToasterItem extends React.Component {
display: false,
message: null,
type: null,
title: null
title: null,
autoClose: true
};
this.dismissToast = this.dismissToast.bind(this);
@ -33,6 +34,7 @@ class ToasterItem extends React.Component {
display: props.display,
type: props._type,
title: props.title,
autoClose: props.autoClose,
toastId: props.toastId
});
} else {
@ -41,6 +43,7 @@ class ToasterItem extends React.Component {
message: null,
type: null,
title: null,
autoClose: true,
toastId: null
});
}
@ -52,7 +55,7 @@ class ToasterItem extends React.Component {
renderToast() {
// ensure that setTimeout is called only once for each toast message
if (!this.timeoutHandler) {
if (this.state.autoClose && !this.timeoutHandler) {
this.timeoutHandler = setTimeout(() => {
this.dismissToast(this.state.toastId);
}, DISPLAY_LENGTH_MILLIS);

4
react/src/components/toaster/toaster.js

@ -27,10 +27,6 @@ class Toaster extends React.Component {
}
}
dismissToast(toastId) {
Store.dispatch(dismissToasterMessage(toastId));
}
renderToasts() {
if (this.state.toasts &&
this.state.toasts.length) {

Loading…
Cancel
Save