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

Alert bug exploration #249

Merged
merged 8 commits into from
Aug 10, 2020
Merged

Alert bug exploration #249

merged 8 commits into from
Aug 10, 2020

Conversation

stephencelis
Copy link
Member

A user encountered a bug here: https://forums.swift.org/t/how-to-show-alerts-from-two-actions-one-after-the-other/39214

This branch should hopefully fix!

@@ -105,6 +105,7 @@ import SwiftUI
@available(tvOS 13, *)
@available(watchOS 6, *)
public struct ActionSheetState<Action> {
public let id = UUID()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to identify in this fashion.

@@ -163,16 +163,11 @@ extension View {
dismiss: Action
) -> some View {

let viewStore = ViewStore(store, removeDuplicates: { ($0 == nil) != ($1 == nil) })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the primary issue. Replacing alert state outright would consider the change a duplicate.

@@ -127,23 +128,44 @@ public struct ActionSheetState<Action> {
@available(macOS, unavailable)
@available(tvOS 13, *)
@available(watchOS 6, *)
extension ActionSheetState: Equatable where Action: Equatable {}
extension ActionSheetState: Equatable where Action: Equatable {
public static func == (lhs: Self, rhs: Self) -> Bool {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have to do custom implementations of Equatable, Hashable, and CustomDebugOutputConvertible now to avoid the UUID being different in tests...maybe you have a better idea than hiding a UUID inside?

Copy link
Member

@mbrandonw mbrandonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Seems like a good way to do this.

@stephencelis stephencelis merged commit 7f482ac into main Aug 10, 2020
@stephencelis stephencelis deleted the alert-bug-exploration branch August 10, 2020 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants