damus icon indicating copy to clipboard operation
damus copied to clipboard

Fix PostView screen freeze when posting long note

Open aki-mizu opened this issue 2 years ago • 4 comments

Currently when user tries to send a long enough note that takes time to get response from relays, the PostView screen freezes until note was sent successfully. This creates a bad user experience that user might tap post button again when PostView screen is frozen, which takes even longer time plus duplicate content will be sent again. This pull request tries to solve this problem by closing PostView immediately after tapping post button. The 0.3 seconds delay is needed because it takes roughly 0.3 seconds for the PostView to disappear completely.

aki-mizu avatar Feb 03 '23 10:02 aki-mizu

hmm ok... but why is it blocking? It should be instant. seems weird...

jb55 avatar Feb 04 '23 18:02 jb55

As far as I know because NSNotificationCenter is synchronous. It must wait for the observer's handler to complete before the next line of execution can happen. That’s why the dismiss method won’t be called unless onReceive(handle_notify(.post) finishes send event causing blocking of PostView screen. https://developer.apple.com/forums/thread/652771

aki-mizu avatar Feb 04 '23 23:02 aki-mizu

hmm ok i'll test and merge this soon

jb55 avatar Feb 06 '23 19:02 jb55

A new commit has been added to make it easier to call send_post function. It should work the same as before.

aki-mizu avatar Feb 06 '23 23:02 aki-mizu

should be fixed now

jb55 avatar Aug 06 '23 04:08 jb55