Skip to content

Commit

Permalink
Only update items if menu is on top
Browse files Browse the repository at this point in the history
Only override the items if the item menu is the current
menu in the stack. Otherwise updates will create a new
directory item for this one without a menu and we loose
the query.
  • Loading branch information
Dirk Meyer committed Jan 4, 2015
1 parent 15451e9 commit eb5862a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/directory.py
Expand Up @@ -140,7 +140,6 @@ def __calculate_num_items(self, type):
self.num_items_dict['dir%s' % media_type] = len(listing.get('beacon:dir'))
self.num_items_dict['all%s' % media_type] = num + len(listing.get('beacon:dir'))
self.num_items_dict = self.num_items_dict
self.menustack.refresh()

@property
def num_items(self):
Expand Down Expand Up @@ -275,13 +274,24 @@ def browse(self):
return
self.item_menu = None
self._beacon_query = yield kaa.beacon.query(parent=self.info)
self._beacon_query.signals['changed'].connect_weak(self._get_items)
self._beacon_query.signals['changed'].connect_weak(self._query_update)
self._beacon_query.monitor()
item_menu = freevo.Menu(self.name, self._get_items(False), type = self.menu_type)
item_menu = freevo.Menu(self.name, self._get_items(False), self._get_items, type = self.menu_type)
item_menu.autoselect = self.config2value('autoplay_single_item')
self.menustack.pushmenu(item_menu)
self.item_menu = weakref(item_menu)

def _query_update(self):
"""
Query update from kaa.beacon
"""
if self.item_menu and self.item_menu == self.menustack[-1]:
# Only override the items if the item menu is the current
# menu in the stack. Otherwise updates will create a new
# directory item for this one without a menu and we loose
# the query.
self._get_items()

def _get_items(self, update=True):
"""
Get the items.
Expand Down

0 comments on commit eb5862a

Please sign in to comment.