Merge lp:~stolowski/unity-scope-home/preview-on-lmb into lp:unity-scope-home

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 98
Merged at revision: 97
Proposed branch: lp:~stolowski/unity-scope-home/preview-on-lmb
Merge into: lp:unity-scope-home
Diff against target: 81 lines (+29/-18)
1 file modified
src/scope.vala (+29/-18)
To merge this branch: bzr merge lp:~stolowski/unity-scope-home/preview-on-lmb
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+160329@code.launchpad.net

Commit message

Display preview for More Suggestions also on left-mouse-click.

Description of the change

Display preview for More Suggestions also on left-mouse-click.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

9 + internal async void handle_metrics (uint action_type, string scope_id, string session_id, string server_sid)
10 {
11 + if (server_sid == null)
12 + return;

You don't allow server_sid to be null ("string server_sid", no "string? server_sid"), so the check is useless.

55 + (activation.action_type == Unity.Protocol.ActionType.ACTIVATE_RESULT ||
56 + activation.action_type == Unity.Protocol.ActionType.PREVIEW_RESULT))

Shouldn't this check if the scope is really remote? Or is that check done earlier?

review: Needs Fixing
97. By Paweł Stołowski

Fixed server_sid check.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
98. By Paweł Stołowski

Make sure more_suggestions is a remote scope when handling preview for it.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

> 9 + internal async void handle_metrics (uint action_type, string
> scope_id, string session_id, string server_sid)
> 10 {
> 11 + if (server_sid == null)
> 12 + return;
>
> You don't allow server_sid to be null ("string server_sid", no "string?
> server_sid"), so the check is useless.

Right. Fixed.

>
> 55 + (activation.action_type ==
> Unity.Protocol.ActionType.ACTIVATE_RESULT ||
> 56 + activation.action_type ==
> Unity.Protocol.ActionType.PREVIEW_RESULT))
>
> Shouldn't this check if the scope is really remote? Or is that check done
> earlier?
We don't really have local "more_suggestions-*" scopes but you're right. Added an extra check just to be safe.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

Looks reasonable, I don't think the "yield handle_metrics ();" should be right after "yield handle_preview ()", but as we discussed this will be fixed in another branch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/scope.vala'
--- src/scope.vala 2013-04-22 12:28:51 +0000
+++ src/scope.vala 2013-04-23 17:15:30 +0000
@@ -381,15 +381,20 @@
381 return true;381 return true;
382 }382 }
383383
384 internal async void handle_metrics (Unity.AggregatorActivation activation, string scope_id, string session_id, string server_sid)384 internal async void handle_metrics (uint action_type, string scope_id, string session_id, string? server_sid)
385 {385 {
386 // server_sid may be null if we didn't query smart scopes service
387 if (server_sid == null)
388 return;
389
390 debug ("Adding activation metrics record for scope %s, action_type=%u", scope_id, action_type);
386 var timestamp = new DateTime.now_utc ();391 var timestamp = new DateTime.now_utc ();
387392
388 if (activation.action_type == Unity.Protocol.ActionType.ACTIVATE_RESULT)393 if (action_type == Unity.Protocol.ActionType.ACTIVATE_RESULT)
389 {394 {
390 sss_client.add_click_event (session_id, server_sid, scope_id, timestamp);395 sss_client.add_click_event (session_id, server_sid, scope_id, timestamp);
391 }396 }
392 else if (activation.action_type == Unity.Protocol.ActionType.PREVIEW_RESULT)397 else if (action_type == Unity.Protocol.ActionType.PREVIEW_RESULT)
393 {398 {
394 sss_client.add_preview_event (session_id, server_sid, scope_id, timestamp);399 sss_client.add_preview_event (session_id, server_sid, scope_id, timestamp);
395 }400 }
@@ -471,7 +476,9 @@
471 {476 {
472 debug ("Activation request for scope %s, action_type=%u", activation.scope_id, activation.action_type);477 debug ("Activation request for scope %s, action_type=%u", activation.scope_id, activation.action_type);
473478
474 if (!scope_mgr.remote_content_search || sss_client == null)479 if (!scope_mgr.remote_content_search || sss_client == null ||
480 (activation.action_type != Unity.Protocol.ActionType.ACTIVATE_RESULT &&
481 activation.action_type != Unity.Protocol.ActionType.PREVIEW_RESULT))
475 return null; //nothing to do482 return null; //nothing to do
476 483
477 string? server_sid = channel_id_map.server_sid_for_channel (activation.channel_id);484 string? server_sid = channel_id_map.server_sid_for_channel (activation.channel_id);
@@ -480,24 +487,28 @@
480 var scope_id = activation.scope_id; //this is an id of master (or a standalone scope such as apps)487 var scope_id = activation.scope_id; //this is an id of master (or a standalone scope such as apps)
481 var scope_id_var = activation.scope_result.metadata.lookup ("scope-id");488 var scope_id_var = activation.scope_result.metadata.lookup ("scope-id");
482489
483 // server_sid may be null if we didn't query smart scopes service490 if (scope_id_var != null)
484 if (server_sid != null)491 scope_id = scope_id_var.get_string ();
492 else
493 debug ("No specific scope_id in the result from master '%s'", scope_id);
494
495 bool is_local_scope = scope_mgr.is_client_scope (scope_id) || ScopeRegistry.instance ().is_master (scope_id);
496
497 // special case for more suggestions in home lens: both lmb & rmb should display a preview
498 if (scope_id.has_prefix ("more_suggestions-") &&
499 !is_local_scope &&
500 (activation.action_type == Unity.Protocol.ActionType.ACTIVATE_RESULT ||
501 activation.action_type == Unity.Protocol.ActionType.PREVIEW_RESULT))
485 {502 {
486 if (scope_id_var != null)503 var preview = yield handle_preview (activation, session_id, server_sid);
487 {504 yield handle_metrics (Unity.Protocol.ActionType.PREVIEW_RESULT, scope_id, session_id, server_sid);
488 scope_id = scope_id_var.get_string ();505 return preview;
489 debug ("Adding activation metrics record for scope %s", scope_id);
490 }
491 else
492 {
493 debug ("No specific scope_id in the result from master '%s'", scope_id);
494 }
495
496 yield handle_metrics (activation, scope_id, session_id, server_sid);
497 }506 }
498507
508 yield handle_metrics (activation.action_type, scope_id, session_id, server_sid);
509
499 // do nothing for local scopes - activation will be handled by actual scope510 // do nothing for local scopes - activation will be handled by actual scope
500 if (scope_mgr.is_client_scope (scope_id) || ScopeRegistry.instance ().is_master (scope_id))511 if (is_local_scope)
501 {512 {
502 debug ("Scope %s is a local scope, passing request to it", scope_id);513 debug ("Scope %s is a local scope, passing request to it", scope_id);
503 return null;514 return null;

Subscribers

People subscribed via source and target branches

to all changes: