Merge pull request #845 from croneter/update-widgets

Refresh widgets only on homescreen to prevent cursor from jumping within libraries
This commit is contained in:
croneter 2019-05-28 20:11:49 +02:00 committed by GitHub
commit 3e7533d965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View file

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

View file

@ -3,7 +3,7 @@
from __future__ import absolute_import, division, unicode_literals from __future__ import absolute_import, division, unicode_literals
import xbmc import xbmc
from .. import utils, variables as v from .. import utils, app, variables as v
PLAYLIST_SYNC_ENABLED = (v.DEVICE != 'Microsoft UWP' and PLAYLIST_SYNC_ENABLED = (v.DEVICE != 'Microsoft UWP' and
utils.settings('enablePlaylistSync') == 'true') 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 Updates the Kodi library and thus refreshes the Kodi views and widgets
""" """
if video: 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: if music:
xbmc.executebuiltin('UpdateLibrary(music)') xbmc.executebuiltin('UpdateLibrary(music)')

View file

@ -486,6 +486,8 @@ class Service(object):
elif plex_command == 'EXIT-PKC': elif plex_command == 'EXIT-PKC':
LOG.info('Received command from another instance to quit') LOG.info('Received command from another instance to quit')
app.APP.stop_pkc = True app.APP.stop_pkc = True
else:
raise RuntimeError('Unknown command: %s', plex_command)
if task: if task:
backgroundthread.BGThreader.addTasksToFront([task]) backgroundthread.BGThreader.addTasksToFront([task])
continue continue
@ -494,6 +496,15 @@ class Service(object):
xbmc.sleep(100) xbmc.sleep(100)
continue 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: # Before proceeding, need to make sure:
# 1. Server is online # 1. Server is online
# 2. User is set # 2. User is set