Skip to content

Commit

Permalink
Fix remote preview for channels
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Dec 23, 2020
1 parent 8086fd9 commit 1c93a9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from tribler_core.modules.metadata_store.serialization import CHANNEL_TORRENT, COLLECTION_NODE, REGULAR_TORRENT
from tribler_core.restapi.rest_endpoint import RESTEndpoint

# This dict is used to translate JSON fields into the columns used in Pony for _sorting_.
# id_ is not in the list because there is not index on it, so we never really want to sort on it.
json2pony_columns = {
'category': "tags",
'id': "rowid",
'name': "title",
'size': "size",
'infohash': "infohash",
Expand All @@ -16,7 +17,7 @@
'health': 'HEALTH',
}

# TODO: use the same representation for metatada nodes as in the database
# TODO: use the same representation for metadata nodes as in the database
metadata_type_to_search_scope = {
'': frozenset((REGULAR_TORRENT, CHANNEL_TORRENT, COLLECTION_NODE)),
"channel": frozenset((CHANNEL_TORRENT, COLLECTION_NODE)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def sanitize_parameters(self, parameters):
sanitized["metadata_type"] = [str(mt) for mt in sanitized["metadata_type"] if mt]
if "channel_pk" in parameters:
sanitized["channel_pk"] = parameters["channel_pk"]
if "origin_id" in parameters:
sanitized["origin_id"] = parameters["origin_id"]

return sanitized

Expand Down
20 changes: 11 additions & 9 deletions src/tribler-gui/tribler_gui/widgets/channelcontentswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ def push_channels_stack(self, model):
self.channels_stack.append(model)
connect(self.model.info_changed, self.on_model_info_changed)

connect(self.window().core_manager.events_manager.received_remote_query_results,
self.model.on_new_entry_received)
connect(
self.window().core_manager.events_manager.received_remote_query_results, self.model.on_new_entry_received
)
connect(self.window().core_manager.events_manager.node_info_updated, self.model.update_node_info)

with self.freeze_controls():
Expand Down Expand Up @@ -239,8 +240,9 @@ def reset_view(self):
def disconnect_current_model(self):
self.model.info_changed.disconnect()
disconnect(self.window().core_manager.events_manager.node_info_updated, self.model.update_node_info)
disconnect(self.window().core_manager.events_manager.received_remote_query_results,
self.model.on_new_entry_received)
disconnect(
self.window().core_manager.events_manager.received_remote_query_results, self.model.on_new_entry_received
)
self.controller.unset_model() # Disconnect the selectionChanged signal

def go_back(self, checked=False):
Expand Down Expand Up @@ -288,12 +290,12 @@ def preview_clicked(self, checked=False):
params = dict()

if "public_key" in self.model.channel_info:
# This is a channel contents query, limit the search by channel_pk and torrent md type
params.update({'metadata_type': 'torrent', 'channel_pk': self.model.channel_info["public_key"]})
elif self.model.text_filter:
# GigaChannel Community v1.0 does not support searching for text in a specific channel
# This is a channel contents query, limit the search by channel_pk and origin_id
params.update(
{'channel_pk': self.model.channel_info["public_key"], 'origin_id': self.model.channel_info["id"]}
)
if self.model.text_filter:
params.update({'txt_filter': self.model.text_filter})

if self.model.hide_xxx is not None:
params.update({'hide_xxx': self.model.hide_xxx})
if self.model.sort_by is not None:
Expand Down

0 comments on commit 1c93a9f

Please sign in to comment.