Refresh widgets only on homescreen to prevent cursor from jumping within libraries

This commit is contained in:
croneter 2019-05-01 08:56:11 +02:00
parent edb9d6e2b0
commit 7e829c1bad
3 changed files with 20 additions and 2 deletions

View file

@ -27,6 +27,8 @@ class App(object):
self.stop_pkc = False
# This will suspend the main thread also
self.suspend = False
# Update Kodi widgets
self.update_widgets = False
# Need to lock all methods and functions messing with Plex Companion subscribers
self.lock_subscriber = RLock()
# Need to lock everything messing with Kodi/PKC playqueues

View file

@ -3,7 +3,7 @@
from __future__ import absolute_import, division, unicode_literals
import xbmc
from .. import utils, variables as v
from .. import utils, app, variables as v
PLAYLIST_SYNC_ENABLED = (v.DEVICE != 'Microsoft UWP' and
utils.settings('enablePlaylistSync') == 'true')
@ -42,7 +42,12 @@ def update_kodi_library(video=True, music=True):
Updates the Kodi library and thus refreshes the Kodi views and widgets
"""
if video:
xbmc.executebuiltin('UpdateLibrary(video)')
if not xbmc.getCondVisibility('Window.IsMedia'):
xbmc.executebuiltin('UpdateLibrary(video)')
else:
# Prevent cursor from moving - refresh later
xbmc.executebuiltin('Container.Refresh')
app.APP.update_widgets = True
if music:
xbmc.executebuiltin('UpdateLibrary(music)')

View file

@ -486,6 +486,8 @@ class Service(object):
elif plex_command == 'EXIT-PKC':
LOG.info('Received command from another instance to quit')
app.APP.stop_pkc = True
else:
raise RuntimeError('Unknown command: %s', plex_command)
if task:
backgroundthread.BGThreader.addTasksToFront([task])
continue
@ -494,6 +496,15 @@ class Service(object):
xbmc.sleep(100)
continue
if app.APP.update_widgets and not xbmc.getCondVisibility('Window.IsMedia'):
'''
In case an update happened but we were not on the homescreen
and now we are, force widgets to update. Prevents cursor from
moving/jumping in libraries
'''
app.APP.update_widgets = False
xbmc.executebuiltin('UpdateLibrary(video)')
# Before proceeding, need to make sure:
# 1. Server is online
# 2. User is set