Closed juanj closed 1 year ago
@juanj thanks so much for your contribution and patience! we've reviewed and tested this PR to be ready for release in the next version update. I've added record of this contribution to your Habitica account as well :)
Closes #1267.
The app was crashing when opening a guild link because an IBOutlet on HabiticaSplitViewController.swift was accessed before it was loaded:
This sometimes happened because of a race condition. When handling a guild link, and instance of
SplitSocialViewController
is created, and the propertygroupID
is set.https://github.com/HabitRPG/habitica-ios/blob/a886a63330923d7f55f8493d920fd1c9615a0dfb/HabitRPG/Utilities/RouterHandler.swift#L70-L74
The property has a
didSet
property observer that dispatches a call toviewDidLayoutSubviews
to the main thread. Most of the time, this call was executed before the view had a chance to be loaded and the IBOutles were connected. Thus crashing as soon as one of the outlet was accessed.https://github.com/HabitRPG/habitica-ios/blob/a886a63330923d7f55f8493d920fd1c9615a0dfb/HabitRPG/UI/Social/SplitSocialViewController.swift#L24-L34
This PR fixes the crash by adding an extra check inside the
viewDidLayoutSubviews
method, to make sure IBOutles are not accessed before the view has been loaded.Habitica User-ID:
2cedef5a-666a-484b-bd97-726209679923