Skip to content

Commit

Permalink
Merge pull request #364 from loathingKernel/next
Browse files Browse the repository at this point in the history
Enable launchable addons such as Fortnite Experiences as games in the library.
  • Loading branch information
loathingKernel authored Jan 2, 2024
2 parents a8a1a84 + 339fec2 commit 4e0f3ab
Show file tree
Hide file tree
Showing 44 changed files with 764 additions and 750 deletions.
25 changes: 13 additions & 12 deletions rare/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _handler(self, exc_type, exc_value, exc_tb) -> bool:
except Exception as e:
self.logger.fatal(str(e))
QMessageBox.warning(None, "Error", self.tr("Failed to login"))
QApplication.exit(1)
QApplication.quit()
return False


Expand All @@ -51,7 +51,7 @@ def __init__(self, args: Namespace):
# set Application name for settings
self.main_window: Optional[MainWindow] = None
self.launch_dialog: Optional[LaunchDialog] = None
self.timer: Optional[QTimer] = None
self.relogin_timer: Optional[QTimer] = None

# This launches the application after it has been instantiated.
# The timer's signal will be serviced once we call `exec()` on the application
Expand All @@ -61,15 +61,15 @@ def poke_timer(self):
dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1]).replace(tzinfo=timezone.utc)
dt_now = datetime.utcnow().replace(tzinfo=timezone.utc)
td = abs(dt_exp - dt_now)
self.timer.start(int(td.total_seconds() - 60) * 1000)
self.relogin_timer.start(int(td.total_seconds() - 60) * 1000)
self.logger.info(f"Renewed session expires at {self.core.lgd.userdata['expires_at']}")

def re_login(self):
def relogin(self):
self.logger.info("Session expires shortly. Renew session")
try:
self.core.login()
self.core.login(force_refresh=True)
except requests.exceptions.ConnectionError:
self.timer.start(3000) # try again if no connection
self.relogin_timer.start(3000) # try again if no connection
return
self.poke_timer()

Expand All @@ -85,8 +85,9 @@ def launch_app(self):

@pyqtSlot()
def __on_start_app(self):
self.timer = QTimer()
self.timer.timeout.connect(self.re_login)
self.relogin_timer = QTimer(self)
self.relogin_timer.setTimerType(Qt.VeryCoarseTimer)
self.relogin_timer.timeout.connect(self.relogin)
self.poke_timer()

self.main_window = MainWindow()
Expand All @@ -105,10 +106,10 @@ def __on_start_app(self):
def __on_exit_app(self, exit_code=0):
threadpool = QThreadPool.globalInstance()
threadpool.waitForDone()
if self.timer is not None:
self.timer.stop()
self.timer.deleteLater()
self.timer = None
if self.relogin_timer is not None:
self.relogin_timer.stop()
self.relogin_timer.deleteLater()
self.relogin_timer = None
self.rcore.deleteLater()
del self.rcore
self.processEvents()
Expand Down
94 changes: 0 additions & 94 deletions rare/components/dialogs/cloud_save_dialog.py

This file was deleted.

Loading

0 comments on commit 4e0f3ab

Please sign in to comment.