Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing multiple toasts in a single frame panics #55

Open
tvolk131 opened this issue Oct 12, 2024 · 0 comments
Open

Closing multiple toasts in a single frame panics #55

tvolk131 opened this issue Oct 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tvolk131
Copy link
Contributor

Currently we close toasts by their index in the toasts array. This works fine unless we're closing multiple toasts within one update call, in which case the first toast will be closed correctly, but the index of all subsequent toasts will be 1 less than before when processing other toast close events. This results in incorrect toasts being closed or, even more problematically, the following code panicking since we're calling Vec::remove() on an index that no longer exists:

keystache/src/app.rs

Lines 146 to 150 in b844ad4

Message::CloseToast(index) => {
self.toasts.remove(index);
Task::none()
}

Toast closing should be idempotent and order-independent. The easiest way to achieve this would be to add a UUID to each toast, and on close, filter toasts excluding that UUID rather than removing by exact index.

@tvolk131 tvolk131 added the bug Something isn't working label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant