quick frontend (app): added AUTO_RESYNC attribute in QuickApp, when set (default) the resync method is called on all widgets automatically:
if AUTO_RESYNC is False, frontend must call itself the resync method. This is useful to improve performance, resynchronising all widgets at once may be resource intensive, and it may be more efficient to resync a widget only when it is visible.
This commit is contained in:
parent
fe4a6abfae
commit
465d9ad62e
1 changed files with 18 additions and 12 deletions
|
|
@ -277,9 +277,13 @@ class ProfilesManager(object):
|
|||
class QuickApp(object):
|
||||
"""This class contain the main methods needed for the frontend"""
|
||||
|
||||
MB_HANDLER = True # Set to False if the frontend doesn't manage microblog
|
||||
AVATARS_HANDLER = True # set to False if avatars are not used
|
||||
ENCRYPTION_HANDLERS = True # set to False if encryption is handled separatly
|
||||
MB_HANDLER = True #: Set to False if the frontend doesn't manage microblog
|
||||
AVATARS_HANDLER = True #: set to False if avatars are not used
|
||||
ENCRYPTION_HANDLERS = True #: set to False if encryption is handled separatly
|
||||
#: if True, QuickApp will call resync itself, on all widgets at the same time
|
||||
#: if False, frontend must call resync itself when suitable (e.g. widget is being
|
||||
#: visible)
|
||||
AUTO_RESYNC = True
|
||||
|
||||
def __init__(self, bridge_factory, xmlui, check_options=None, connect_bridge=True):
|
||||
"""Create a frontend application
|
||||
|
|
@ -445,18 +449,20 @@ class QuickApp(object):
|
|||
or if connection has been lost and a reconnection is needed
|
||||
"""
|
||||
if state:
|
||||
# we are resynchronising
|
||||
for w in self.widgets:
|
||||
try:
|
||||
resync = w.resync
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
resync()
|
||||
if self.AUTO_RESYNC:
|
||||
# we are resynchronising all widgets
|
||||
for w in self.widgets:
|
||||
try:
|
||||
resync = w.resync
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
resync()
|
||||
self._sync = state
|
||||
else:
|
||||
self._sync = state
|
||||
# we've lost synchronisation
|
||||
# we've lost synchronisation, all widgets must be notified
|
||||
# note: this is always called independently of AUTO_RESYNC
|
||||
for w in self.widgets:
|
||||
try:
|
||||
w.sync = False
|
||||
|
|
|
|||
Loading…
Reference in a new issue