Only update media icon when necessary (#24324)
* Only update media icon when necessary * Lint * Commentpull/24334/head
parent
859ae2fbad
commit
f5db7707bb
|
@ -167,6 +167,7 @@ class LgWebOSDevice(MediaPlayerDevice):
|
|||
self._source_list = {}
|
||||
self._app_list = {}
|
||||
self._channel = None
|
||||
self._last_icon = None
|
||||
|
||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||
def update(self):
|
||||
|
@ -271,6 +272,13 @@ class LgWebOSDevice(MediaPlayerDevice):
|
|||
icon = self._app_list[self._current_source_id]['largeIcon']
|
||||
if not icon.startswith('http'):
|
||||
icon = self._app_list[self._current_source_id]['icon']
|
||||
|
||||
# 'icon' holds a URL with a transient key. Avoid unnecessary
|
||||
# updates by returning the same URL until the image changes.
|
||||
if self._last_icon and \
|
||||
(icon.split('/')[-1] == self._last_icon.split('/')[-1]):
|
||||
return self._last_icon
|
||||
self._last_icon = icon
|
||||
return icon
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue