Skip to content

Commit

Permalink
fix: prevent version request error
Browse files Browse the repository at this point in the history
  • Loading branch information
iholston committed Nov 27, 2024
1 parent cacaebb commit 5a22262
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lolbot/view/about_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@

import dearpygui.dearpygui as dpg

VERSION = '4.0.2'
VERSION = '4.0.3'


class AboutTab:
"""Class that displays the About Tab and information about the bot"""

def __init__(self) -> None:
response = requests.get("https://api.github.com/repos/iholston/lol-bot/releases/latest")
self.version = 'v' + VERSION
self.latest_version = response.json()["name"]
self.version = f"v{VERSION}"
try:
response = requests.get("https://api.github.com/repos/iholston/lol-bot/releases/latest")
self.release_version = response.json()["name"]
except:
self.release_version = self.version
self.need_update = False
if self.latest_version != self.version:
if self.release_version != self.version:
self.need_update = True

def create_tab(self, parent: int) -> None:
Expand All @@ -29,7 +32,7 @@ def create_tab(self, parent: int) -> None:
dpg.add_button(label='Bot Version', width=100, enabled=False)
dpg.add_text(default_value=self.version)
if self.need_update:
update = dpg.add_button(label="- Update Available ({})".format(self.latest_version), callback=lambda: webbrowser.open('https://github.com/iholston/lol-bot/releases/latest'))
update = dpg.add_button(label="- Update Available ({})".format(self.release_version), callback=lambda: webbrowser.open('https://github.com/iholston/lol-bot/releases/latest'))
with dpg.tooltip(dpg.last_item()):
dpg.add_text("Get latest release")
dpg.bind_item_theme(update, "__hyperlinkTheme")
Expand Down

0 comments on commit 5a22262

Please sign in to comment.