Skip to content

Commit

Permalink
Ignore last number (v0.3.14.1 ignores .1) when checking for release n…
Browse files Browse the repository at this point in the history
…otes
  • Loading branch information
kozec committed Aug 16, 2017
1 parent e66e295 commit e83419e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions scc/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,8 @@ def on_daemon_version(self, daemon, version):
# At this point, correct daemon version of daemon is running
# and we can check if there is anything new to inform user about
if self.app.config['gui']['news']['enabled']:
if self.app.config['gui']['news']['last_version'] != DAEMON_VERSION:
self.check_release_notes(DAEMON_VERSION)
if self.app.config['gui']['news']['last_version'] != App.get_release():
self.check_release_notes()


def on_daemon_error(self, daemon, error):
Expand Down Expand Up @@ -1210,19 +1210,28 @@ def load_profile_selection(self):
return None


@staticmethod
def get_release(n=3):
"""
Returns current version rounded to max. 'n' numbers.
( v0.14.1.3 ; n=3 -> v0.14.1 )
"""
return ".".join(DAEMON_VERSION.split(".")[0:n])


def release_notes_visible(self):
""" Returns True if release notes infobox is visible """
if not self.ribar: return False
riNewRelease = self.builder.get_object('riNewRelease')
return self.ribar._infobar == riNewRelease


def check_release_notes(self, version):
def check_release_notes(self):
"""
Silently downloads release notes from github and displays infobar
informing user that they are ready to be displayed.
"""
url = App.RELEASE_URL % (version,)
url = App.RELEASE_URL % (App.get_release(),)
log.debug("Loading release notes from '%s'", url)
f = Gio.File.new_for_uri(url)
buffer = b""
Expand Down Expand Up @@ -1271,10 +1280,10 @@ def on_got_release_notes(self, data):
msg += _("<a href='%s'>Click here</a> to check what's new!")
msg = msg % (extended.group(1), )
else:
url = App.RELEASE_URL % (DAEMON_VERSION, )
url = App.RELEASE_URL % (App.get_release(), )
msg += _("Welcome to the version <b>%s</b>.")
msg += " " + _("<a href='%s'>Click here</a> to read release notes.")
msg = msg % (DAEMON_VERSION, url)
msg = msg % (App.get_release(), url)

infobar = self.builder.get_object('riNewRelease')
lblNewRelease = self.builder.get_object('lblNewRelease')
Expand All @@ -1286,7 +1295,7 @@ def on_got_release_notes(self, data):


def on_new_release_dismissed(self, *a):
self.config['gui']['news']['last_version'] = DAEMON_VERSION
self.config['gui']['news']['last_version'] = App.get_release()
self.config.save()


Expand Down

0 comments on commit e83419e

Please sign in to comment.