Toast icon indicating copy to clipboard operation
Toast copied to clipboard

On notification subtitle show time elapsed since notification shown

Open slimninja opened this issue 5 years ago • 2 comments

On creation of toast, set date-created attribute to Date.now() and then have a recursive timeout to update the subtitle. On notification dismiss, destroy the chain.

Dirty non-working example:

function updateToastStatus(toast) {
    var data = toast.data();
    startTime = data.created
    // logic to update subtitle to show now, 5 seconds ago, 10 min ago, etc
    setTimeout(updateToastStatus, 5000);
}

updateToastStatus(toast); // First call starts process

image

Planning on taking care of this at some point, I'll update here if I do.

slimninja avatar Nov 26 '20 19:11 slimninja

How would this affect those toasts which already have a subtitle?

Script47 avatar Nov 26 '20 23:11 Script47

Id keep this as a seperate option on toast definition, as it would have some performance impact based on number of toasts you're creating.

slimninja avatar Nov 26 '20 23:11 slimninja