From ef44cb852cd80d28d1b9396407f454d8a871f473 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 21 Dec 2022 18:26:32 +0700 Subject: [PATCH] add new version notification to UI --- tubearchivist/home/src/ta/config.py | 12 ++++++++++-- tubearchivist/home/templates/home/base.html | 9 ++++++++- tubearchivist/home/views.py | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tubearchivist/home/src/ta/config.py b/tubearchivist/home/src/ta/config.py index 27e0cf1d..64d5d216 100644 --- a/tubearchivist/home/src/ta/config.py +++ b/tubearchivist/home/src/ta/config.py @@ -326,10 +326,18 @@ class ReleaseVersion: def is_updated(self): """check if update happened in the mean time""" - message = RedisArchivist().get_message(self.NEW_KEY) - if not message.get("status"): + message = self.get_update() + if not message: return if self._parse_version(message.get("version")) == self.local_version: print(f"[{self.local_version}]: update completed") RedisArchivist().del_message(self.NEW_KEY) + + def get_update(self): + """return new version dict if available""" + message = RedisArchivist().get_message(self.NEW_KEY) + if not message.get("status"): + return False + + return message diff --git a/tubearchivist/home/templates/home/base.html b/tubearchivist/home/templates/home/base.html index 71b7dceb..2adce0d3 100644 --- a/tubearchivist/home/templates/home/base.html +++ b/tubearchivist/home/templates/home/base.html @@ -132,7 +132,14 @@ diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 427a463b..bdf9b27d 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -36,7 +36,7 @@ from home.src.index.channel import YoutubeChannel, channel_overwrites from home.src.index.generic import Pagination from home.src.index.playlist import YoutubePlaylist from home.src.index.reindex import ReindexProgress -from home.src.ta.config import AppConfig, ScheduleBuilder +from home.src.ta.config import AppConfig, ReleaseVersion, ScheduleBuilder from home.src.ta.helper import UrlListParser, time_parser from home.src.ta.ta_redis import RedisArchivist from home.tasks import extrac_dl, index_channel_playlists, subscribe_to @@ -138,6 +138,7 @@ class ArchivistViewConfig(View): "show_ignored_only": self._get_show_ignore_only(), "show_subed_only": self._get_show_subed_only(), "version": settings.TA_VERSION, + "ta_update": ReleaseVersion().get_update(), } @@ -266,6 +267,7 @@ class MinView(View): return { "colors": AppConfig(request.user.id).colors, "version": settings.TA_VERSION, + "ta_update": ReleaseVersion().get_update(), }