Introduce a concept of "non-urgent" toasts

This is somewhat expected to be temporary.
This commit is contained in:
Travis Ralston 2020-07-29 12:43:35 -06:00
parent 6a9fe35fa8
commit 14757cacd5
7 changed files with 159 additions and 3 deletions

View file

@ -15,9 +15,10 @@ limitations under the License.
*/
import EventEmitter from "events";
import React, {JSXElementConstructor} from "react";
import React from "react";
import { ComponentClass } from "../@types/common";
export interface IToast<C extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> {
export interface IToast<C extends ComponentClass> {
key: string;
// higher priority number will be shown on top of lower priority
priority: number;
@ -55,7 +56,7 @@ export default class ToastStore extends EventEmitter {
*
* @param {object} newToast The new toast
*/
addOrReplaceToast<C extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>>(newToast: IToast<C>) {
addOrReplaceToast<C extends ComponentClass>(newToast: IToast<C>) {
const oldIndex = this.toasts.findIndex(t => t.key === newToast.key);
if (oldIndex === -1) {
let newIndex = this.toasts.length;