mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 14:45:46 +01:00
Cleanup
This commit is contained in:
parent
3f5b3941f6
commit
94f116553d
2 changed files with 0 additions and 14 deletions
|
|
@ -20,10 +20,6 @@ class UpdateInfo:
|
|||
class UpdateChecker(QObject):
|
||||
update_available = pyqtSignal(object)
|
||||
|
||||
no_update_available = pyqtSignal()
|
||||
|
||||
check_failed = pyqtSignal(str)
|
||||
|
||||
VERSION_JSON_URL = "https://github.com/chidiwilliams/buzz/releases/latest/download/version_info.json"
|
||||
|
||||
CHECK_INTERVAL_DAYS = 7
|
||||
|
|
@ -73,7 +69,6 @@ class UpdateChecker(QObject):
|
|||
def check_for_updates(self) -> None:
|
||||
"""Start the network request"""
|
||||
if not self.should_check_for_updates():
|
||||
self.no_update_available.emit()
|
||||
return
|
||||
|
||||
logging.info("Checking for updates...")
|
||||
|
|
@ -92,7 +87,6 @@ class UpdateChecker(QObject):
|
|||
if reply.error() != QNetworkReply.NetworkError.NoError:
|
||||
error_msg = f"Failed to check for updates: {reply.errorString()}"
|
||||
logging.error(error_msg)
|
||||
self.check_failed.emit(error_msg)
|
||||
reply.deleteLater()
|
||||
return
|
||||
|
||||
|
|
@ -129,12 +123,10 @@ class UpdateChecker(QObject):
|
|||
Settings.Key.UPDATE_AVAILABLE_VERSION,
|
||||
""
|
||||
)
|
||||
self.no_update_available.emit()
|
||||
|
||||
except (json.JSONDecodeError, KeyError) as e:
|
||||
error_msg = f"Failed to parse version info: {e}"
|
||||
logging.error(error_msg)
|
||||
self.check_failed.emit(error_msg)
|
||||
|
||||
def _get_download_url(self, download_urls: dict) -> list:
|
||||
system = platform.system()
|
||||
|
|
|
|||
|
|
@ -507,21 +507,15 @@ class MainWindow(QMainWindow):
|
|||
"""Initializes and runs the update checker."""
|
||||
self.update_checker = UpdateChecker(settings=self.settings, parent=self)
|
||||
self.update_checker.update_available.connect(self._on_update_available)
|
||||
self.update_checker.check_failed.connect(self._on_update_check_failed)
|
||||
|
||||
# Check for updates on startup
|
||||
self.update_checker.check_for_updates()
|
||||
|
||||
def _on_update_available(self, update_info: UpdateInfo):
|
||||
"""Called when an update is available."""
|
||||
logging.info(f"Update available: {update_info.version}")
|
||||
self._update_info = update_info
|
||||
self.toolbar.set_update_available(True)
|
||||
|
||||
def _on_update_check_failed(self, error: str):
|
||||
"""Called when update check fails."""
|
||||
logging.warning(f"Update check failed: {error}")
|
||||
|
||||
def on_update_action_triggered(self):
|
||||
"""Called when user clicks the update action in toolbar."""
|
||||
if self._update_info is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue