Closed angrytongan closed 4 years ago
Using Toaster().update() with a new timeout doesn't change the time the toast appears.
Toaster().update()
Click the button 1 second, then 5 second. The toast updates, but the timeout doesn't.
1 second
5 second
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 }); });
Fixed in v0.2.4.
Using
Toaster().update()
with a new timeout doesn't change the time the toast appears.Click the button
1 second
, then5 second
. The toast updates, but the timeout doesn't.