-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix(stickers): fix crash in async task + clean up + set bought status #12676
Conversation
@@ -122,8 +122,11 @@ QtObject: | |||
self.packs.apply(proc(it: var StickerPackView) = | |||
if it.pack.id == packId: | |||
it.installed = installed | |||
if installed: | |||
it.bought = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix for the bought
status (problem 2 in the description)
@@ -68,9 +69,7 @@ const obtainMarketStickerPacksTask: Task = proc(argEncoded: string) {.gcsafe, ni | |||
|
|||
const installStickerPackTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = | |||
let arg = decode[InstallStickerPackTaskArg](argEncoded) | |||
if not arg.hasKey: | |||
arg.finish(false) | |||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix for the crash (problem 1)
@@ -174,10 +174,6 @@ QtObject: | |||
error "Error reverting sticker transaction", message = getCurrentExceptionMsg() | |||
|
|||
proc init*(self: Service) = | |||
# TODO redo the connect check when the network is refactored | |||
# if self.status.network.isConnected: | |||
self.obtainMarketStickerPacks() # TODO: rename this to obtain sticker market items |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix for the double obtainMarketStickerPacks
calls (problem 3)
Jenkins Builds
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
if installedPack.installed: | ||
if self.marketStickerPacks.hasKey(installedPack.packId): | ||
self.marketStickerPacks[installedPack.packId].status = StickerPackStatus.Installed | ||
self.events.emit(SIGNAL_STICKER_PACK_INSTALLED, StickerPackInstalledArgs( | ||
packId: installedPack.packId | ||
)) | ||
else: | ||
error "Sticker pack did not get installed", packId = installedPack.packId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd appreciate quick return with inverted condition, but this is a minor thing ofc 🙂
if not installedPack.installed:
error "Sticker pack did not get installed", packId = installedPack.packId
return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I agree, but also, I'm lazy and the stickers service is pretty messed up, so eff it, I'll merge
Fixes #12664
The issue was that the async task was badly made. It could return
false
instead of a tuple, so it made the app crashed.I fixed it by removing that condition, since I we don't actually care if the pack we are installing is in the cache. Worst case, status-go will return an error and we can handle it. In the better case, it was just a weird problem with the cache and since it exists in the model, it probably exists in the backend, so it would go through anyway. That issue was very random for me and I could trigger it only once.
Another issue I found was that when buying a pack, we set the
installed
property in the model, but notbought
, so if you uninstall the pack, it looks like you didn't buy it. That's fixed.Finally, I found that we called
obtainMarketStickerPacks
twice on app start. I fixed it by only using the one from the front-end, since it's the one that reacts to the online status changing.In an ideal world, that should all be handled by the backend, but it works from the frontend and the whole sticker service is messy, so it's not worth it refactoring it all just for that.
The rest of the changes are just clean ups