Skip to content

Commit

Permalink
feat(extension): add automatic update option for presence
Browse files Browse the repository at this point in the history
  • Loading branch information
manucabral committed Nov 26, 2024
1 parent ccc6eae commit 4dfa23e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rpp/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __load_metadata(self, log: bool = True) -> None:
self.name = metadata.get("name", self.name)
self.author = metadata.get("author", "Unknown")
self.web = metadata.get("web", False)
self.automatic = metadata.get("automatic", True)
self.version = metadata.get("version", None)
self.update_interval = metadata.get("updateInterval", 3)
self.package = metadata.get("package", None)
Expand Down Expand Up @@ -127,7 +128,8 @@ def on_update(self, **context) -> None:
Called when the presence is updated.
"""
super().on_update(**context)
self.update()
if self.automatic:
self.update()

def on_close(self) -> None:
"""
Expand All @@ -147,6 +149,7 @@ def force_update(self) -> None:
"""
Force the presence to update.
"""
self.log.debug("Forcing update.")
self.update()

def __interval_time(self) -> bool:
Expand Down Expand Up @@ -201,9 +204,10 @@ def update(self) -> None:
"""
Update the presence.
"""
ok = self.__interval_time()
if not ok:
return
if self.automatic:
ok = self.__interval_time()
if not ok:
return
if self.dev_mode:
self.log.debug(json.dumps(self.deserialize(), indent=4))
return
Expand Down

0 comments on commit 4dfa23e

Please sign in to comment.