Cache items in get_filter_tree
This commit is contained in:
parent
899c575ae8
commit
affe47a11c
|
@ -34,6 +34,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import copy
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
|
||||||
STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"]
|
STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"]
|
||||||
|
@ -130,6 +131,8 @@ class FilterManager(component.Component):
|
||||||
self.register_filter("keyword", filter_keywords)
|
self.register_filter("keyword", filter_keywords)
|
||||||
self.register_filter("name", filter_by_name)
|
self.register_filter("name", filter_by_name)
|
||||||
self.tree_fields = {}
|
self.tree_fields = {}
|
||||||
|
self.prev_filter_tree_keys = None
|
||||||
|
self.filter_tree_items = None
|
||||||
|
|
||||||
self.register_tree_field("state", self._init_state_tree)
|
self.register_tree_field("state", self._init_state_tree)
|
||||||
def _init_tracker_tree():
|
def _init_tracker_tree():
|
||||||
|
@ -211,7 +214,11 @@ class FilterManager(component.Component):
|
||||||
tree_keys.remove(cat)
|
tree_keys.remove(cat)
|
||||||
|
|
||||||
torrent_keys, plugin_keys = self.torrents.separate_keys(tree_keys, torrent_ids)
|
torrent_keys, plugin_keys = self.torrents.separate_keys(tree_keys, torrent_ids)
|
||||||
items = dict((field, self.tree_fields[field]()) for field in tree_keys)
|
# Keys are the same, so use previous items
|
||||||
|
if self.prev_filter_tree_keys != tree_keys:
|
||||||
|
self.filter_tree_items = dict((field, self.tree_fields[field]()) for field in tree_keys)
|
||||||
|
self.prev_filter_tree_keys = tree_keys
|
||||||
|
items = copy.deepcopy(self.filter_tree_items)
|
||||||
|
|
||||||
for torrent_id in list(torrent_ids):
|
for torrent_id in list(torrent_ids):
|
||||||
status = self.core.create_torrent_status(torrent_id, torrent_keys, plugin_keys) #status={key:value}
|
status = self.core.create_torrent_status(torrent_id, torrent_keys, plugin_keys) #status={key:value}
|
||||||
|
|
Loading…
Reference in New Issue