From 1b566db184f19d349e2c28a0ee1cb8f939ee959a Mon Sep 17 00:00:00 2001 From: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sun, 31 Dec 2023 15:56:41 +0100 Subject: [PATCH] refactor: ProfilePictureDownloader --- .../impl/downloader/ProfilePictureDownloader.kt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/ProfilePictureDownloader.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/ProfilePictureDownloader.kt index 1a60ee95..b0c8014d 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/ProfilePictureDownloader.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/downloader/ProfilePictureDownloader.kt @@ -59,15 +59,8 @@ class ProfilePictureDownloader : Feature("ProfilePictureDownloader", loadParams context.event.subscribe(NetworkApiRequestEvent::class) { event -> if (!event.url.endsWith("/rpc/getPublicProfile")) return@subscribe - Hooker.ephemeralHookObjectMethod(event.callback::class.java, event.callback, "onSucceeded", HookStage.BEFORE) { methodParams -> - val content = methodParams.arg(2).run { - ByteArray(capacity()).also { - get(it) - position(0) - } - } - - ProtoReader(content).followPath(1, 1, 2) { + event.onSuccess { buffer -> + ProtoReader(buffer ?: return@onSuccess).followPath(1, 1, 2) { friendUsername = getString(2) ?: return@followPath followPath(4) { backgroundUrl = getString(2)