Revert "fix: eliminate blocking calls causing startup freezes and UI hangs"

This reverts commit b2a1046f9d.
This commit is contained in:
2025-11-22 11:21:25 +05:00
parent 873e8b050e
commit 30606c7ec1
3 changed files with 18 additions and 59 deletions

View File

@@ -416,24 +416,18 @@ class PortProtonAPI:
self._topics_data = []
self.downloader.download_async(self.topics_url, cache_tar, timeout=5, callback=process_tar)
# Instead of blocking, return cached data if available, or empty list
# The actual data will be loaded asynchronously for future calls
if hasattr(self, '_topics_data') and self._topics_data is not None:
return self._topics_data
else:
# Return empty list as fallback to prevent blocking
# The topics data will be loaded asynchronously in the background
logger.warning("Returning empty topics data, async loading in progress")
return []
# Wait for async download to complete if called synchronously
while self._topics_data is None:
time.sleep(0.1)
return self._topics_data
def get_forum_topic_slug(self, game_name: str) -> str:
"""Get the forum topic slug or search URL for a given game name."""
topics = self._load_topics_data()
if topics: # Only search if topics were loaded
normalized_name = normalize_name(game_name)
for topic in topics:
if topic["normalized_title"] == normalized_name:
return topic["slug"]
normalized_name = normalize_name(game_name)
for topic in topics:
if topic["normalized_title"] == normalized_name:
return topic["slug"]
logger.debug("No forum topic found for game: %s, redirecting to search", game_name)
encoded_name = urllib.parse.quote(f"#ppdb {game_name}")
return f"search?q={encoded_name}"