|
4 | 4 | #include <Geode/modify/ProfilePage.hpp> |
5 | 5 | #include <Geode/utils/web.hpp> |
6 | 6 |
|
| 7 | +std::string badgesDataProfile = ""; |
| 8 | + |
7 | 9 | void NewProfilePage::onBadgePressed(CCObject* pSender) { |
8 | 10 | geode::log::info("Object: {}", static_cast<CCNode*>(pSender)->getUserObject()); |
9 | 11 | CCInteger* score = static_cast<CCInteger*>(static_cast<CCNode*>(pSender)->getUserObject()); |
@@ -192,6 +194,8 @@ class $modify(ProfilePage) { |
192 | 194 |
|
193 | 195 | void requestGDUtilsBadges(int accountID, CCLayer* layer) { |
194 | 196 | const std::function<void(std::string const&)> then = [this, accountID, layer](std::string const& result) { |
| 197 | + badgesDataProfile = result; |
| 198 | + |
195 | 199 | std::vector<std::string> data_user = MoreLeaderboards::getWords(result, "|"); |
196 | 200 |
|
197 | 201 | while (data_user.size() > 0) { |
@@ -269,6 +273,13 @@ class $modify(ProfilePage) { |
269 | 273 | log::error("Failed to get GDUtils badges: {}", error); |
270 | 274 | }; |
271 | 275 |
|
| 276 | + // If we already have the badges data, don't request it again |
| 277 | + if (badgesDataProfile != "") { |
| 278 | + then(badgesDataProfile); |
| 279 | + return; |
| 280 | + } |
| 281 | + |
| 282 | + // Request the badges data |
272 | 283 | m_fields->m_listener.bind([expect = std::move(expect), then = std::move(then)] (web::WebTask::Event* e) { |
273 | 284 | if (web::WebResponse* res = e->getValue()) { |
274 | 285 | if (res->ok()) { |
|
0 commit comments