Skip to content

Commit

Permalink
refactored callers of refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdversluis committed Jul 5, 2016
1 parent 6e6864a commit 7c4028b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Tribler/Main/vwxGUI/GuiUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def subscribe_latestupdate_sort(a, b):

manager = self.frame.channellist.GetManager()
yield manager.SetCategory('searchresults')
manager.refresh(data)
yield manager.refresh(data)

self.ShowPage('channels')

Expand Down
8 changes: 6 additions & 2 deletions Tribler/Main/vwxGUI/SearchGridManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,11 @@ def gotDispersyRemoteHits(self, subject, changetype, objectID, search_results):
else:
self._logger.debug("TorrentSearchGridManager: gotRemoteHist: not scheduling refresh")

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def refreshGrid(self, remote=False):
if self.gridmgr:
self.gridmgr.refresh(remote)
yield self.gridmgr.refresh(remote)

def getThumbnailTorrents(self, is_collected=True, limit=20):
result = []
Expand Down Expand Up @@ -888,9 +890,11 @@ def exists(self, infohashes):
def set_gridmgr(self, gridmgr):
self.gridmgr = gridmgr

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def refreshGrid(self):
if self.gridmgr is not None:
self.gridmgr.refresh()
yield self.gridmgr.refresh()


class ChannelManager(object):
Expand Down
9 changes: 6 additions & 3 deletions Tribler/Main/vwxGUI/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,19 +397,23 @@ def Reset(self):
self.dirtyset.clear()
self.prev_refresh_if = 0

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def do_or_schedule_refresh(self, force_refresh=False):
if self.list.isReady and (self.list.ShouldGuiUpdate() or force_refresh):
diff = time() - self.prev_refresh_if
if diff > 5 or force_refresh:
self.prev_refresh_if = time()
self.refresh()
yield self.refresh()
else:
self.dirtyset.add('COMPLETE_REFRESH')
self.list.dirty = True

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def refreshDirty(self):
if self.category != 'searchresults' and 'COMPLETE_REFRESH' in self.dirtyset or len(self.dirtyset) > 5:
self.refresh()
yield self.refresh()
else:
if 'COMPLETE_REFRESH' in self.dirtyset:
self.dirtyset.remove('COMPLETE_REFRESH')
Expand All @@ -419,7 +423,6 @@ def refreshDirty(self):
self.dirtyset.clear()

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def refresh(self, search_results=None):
self._logger.debug("ChannelManager complete refresh")
if self.category != 'searchresults':
Expand Down
8 changes: 6 additions & 2 deletions Tribler/Main/vwxGUI/list_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,19 +627,23 @@ def updateEditTab(self):
self.editButton.Enable(self.canEdit)
self.notebook.ShowPage(self.notebook.GetIndexFromText('Edit'), self.canEdit)

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def updateCommentsTab(self):
if self.canComment:
commentManager = self.commentList.GetManager()
commentManager.SetIds(self.torrent.channel, channeltorrent=self.torrent)
commentManager.refresh()
yield commentManager.refresh()
self.notebook.ShowPage(self.notebook.GetIndexFromText('Comments'), self.canComment)

@inlineCallbacks
# TODO (Laurens): Refactor callers because deferred.
def updateModificationsTab(self):
show_modifications = self.canEdit or bool(self.torrent.get('description', ''))
if show_modifications:
modificationManager = self.modificationList.GetManager()
modificationManager.SetIds(self.torrent)
modificationManager.refresh()
yield modificationManager.refresh()
self.notebook.ShowPage(self.notebook.GetIndexFromText('Modifications'), show_modifications)

def updateTrackersTab(self):
Expand Down

0 comments on commit 7c4028b

Please sign in to comment.