Timeout attribute not respected in Toaster().update()
angrytongan opened this issue · 1 comments
angrytongan commented
Using Toaster().update()
with a new timeout doesn't change the time the toast appears.
Click the button 1 second
, then 5 second
. The toast updates, but the timeout doesn't.
const {
Button,
Toaster,
} = CUI;
const ToasterUpdate = () => {
const toaster = new Toaster();
const toasterMessages = [
{ name: '1 second', message: '1 second timeout', timeout: 1000 },
{ name: '2 seconds', message: '2 second timeout', timeout: 2000 },
{ name: '5 seconds', message: '5 second timeout', timeout: 5000 },
];
const getToast = (name) => toasterMessages.find((t) => t.name == name);
return {
view: () => {
return [
toasterMessages.map((tm) => m(Button, {
label: tm.name,
onclick: () => {
const existing = toaster.getToasts();
if (existing.length > 0) {
toaster.update(existing[0].key, getToast(tm.name));
} else {
toaster.show(getToast(tm.name))
}
}
})),
m(toaster),
];
},
};
};
document.addEventListener('DOMContentLoaded', () => {
m.route(document.body, '/', {
'/': ToasterUpdate
});
});
vrimar commented
Fixed in v0.2.4.