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

Post closes when focus is lost on iPhone #256

Closed
AntonOellerer opened this issue Mar 6, 2024 · 2 comments · Fixed by #258
Closed

Post closes when focus is lost on iPhone #256

AntonOellerer opened this issue Mar 6, 2024 · 2 comments · Fixed by #258
Assignees
Labels
bug Something isn't working reproduced The bug has been confirmed

Comments

@AntonOellerer
Copy link

AntonOellerer commented Mar 6, 2024

Hey,
First of all, thank you very much for WriteFreely and the iOs App, I have been using it to keep my family up-to-date with my travels for five months now, with great success!

When using the application on my iPhone SE 2nd generation (iOs 17.3), I noticed that whenever the focus changes away from the application while editing a post, the post closes.
In a bit more detail:

Steps to Reproduce:

  1. Create new post
  2. Write some text
  3. Pull up iOs quick settings
  4. Close quick settings

Expected behaviour

Post is still open, ready to be edited

Actual behaviour

Post is closed

@AntonOellerer AntonOellerer changed the title Post closes when focus is lost Post closes when focus is lost on iPhone Mar 6, 2024
@AngeloStavrow AngeloStavrow added bug Something isn't working reproduced The bug has been confirmed labels Mar 16, 2024
@AngeloStavrow AngeloStavrow self-assigned this Mar 16, 2024
@AngeloStavrow
Copy link
Collaborator

@AntonOellerer thanks for reporting this bug — I'm working on a fix. Glad to hear you're finding the app helpful on your travels!

@AngeloStavrow
Copy link
Collaborator

Okay, after a lot of debugging, I've figured out why this is happening in iOS 17.

In the PostListView —the screen that shows the list of posts— there's an onReceive modifier that listens for when the app has become active:

.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
    // We use this to invalidate and refresh the view, so that new posts created outside of the app (e.g.,
    // in the action extension) show up.
    withAnimation {
        self.filteredListViewId += 1
    }
}

As the comment suggests, we use this to force the app to refresh the list. This was added when we added the Safari extension that lets you create a new local draft from selected text on a webpage, so that if you returned to the app the list would reload and show the new, extension-created local draft.

Commenting out this code fixes the bug you reported, but breaks the ability to refresh the list of posts when the app becomes active. I'm investigating to see why this broke in iOS 17, when it was working as expected previously. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproduced The bug has been confirmed
Development

Successfully merging a pull request may close this issue.

2 participants