~zhangew401/scope-aggregator/fix-empty-query-to-clickstore

« back to all changes in this revision

Viewing changes to src/query.cpp

  • Committer: Kyle Nitzsche
  • Date: 2016-03-03 16:20:10 UTC
  • mfrom: (158.1.2 hints-using-data)
  • Revision ID: kyle.nitzsche@canonical.com-20160303162010-xpszljtnfu1ziwh0
Tags: 4.4
Merge that works withi/requires 1.0 version of hints scope as follows:

Previously when hints quickstart displayed and user tapped "Skip" button
the hints scope set the uri on the Skip button result like so:
scope://com.canonical.scopes.dashboard_dashbiard?q=start

The result was that the "start" string displayed in the agg scope search
box, which is not great.  

The agg scope looked for an incoming query string of "start" and if found
it treated it as signal to dismiss hints quick start (by writing a file
to cache dir, a file that is checked on every refresh).

This merge changes the expectation of the agg scope as follows:

The signal to dismiss hints now takes the form of user_data of 
"hide_quickstart" in the incoming uri, for example:
        std::string data = query().user_data().get_string();
        if (data == "hide_quickstart")
        ... then write the file to dismiss hints.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 
104
104
    load_hints();
105
105
 
 
106
    bool hide_hints_quickstart = false;
 
107
 
106
108
    qDebug() << "==== HINTS. uses_hints" << uses_hints;
107
109
    qDebug() << "==== HINTS. display_hints_on_firstuse" << hints_quickstart;
108
110
    qDebug() << "==== HINTS. query_string" << qstr(query_string);
109
111
 
110
 
    if (uses_hints && hints_quickstart && hints_exists() && query_string == HINTS_HIDE)
111
 
    {
112
 
        dismiss_hints_quickstart();
113
 
        // when dismissing hints, query string must be set to "" to prevent subsearching 
114
 
        // child scopes.
115
 
        query_string = "";
116
 
    }
117
 
 
118
 
    if (uses_hints && hints_quickstart && hints_exists() && !is_hints_quickstart_dismissed())
119
 
    {
120
 
        display_hints_quickstart(upstream_reply);
121
 
        return;
 
112
    // user data can show whether to hide hints quickstart
 
113
    if (query().has_user_data())
 
114
    {
 
115
        try 
 
116
        {
 
117
            std::string data = query().user_data().get_string();
 
118
            if (data == "hide_quickstart")
 
119
            {
 
120
                hide_hints_quickstart = true;
 
121
             }
 
122
        } catch (unity::LogicException &e)
 
123
        {
 
124
            qWarning() << "=== HINTS. cannot get data from canned query";
 
125
        }
 
126
    }
 
127
 
 
128
    qDebug() << "=== HINTS CQ hide hints: " << hide_hints_quickstart;
 
129
    qDebug() << "=== HINTS hints_hidden: " << hints_hidden();
 
130
    bool show_normal = true;
 
131
 
 
132
 /*
 
133
 * Note: To redisplay hints at runtime, touch "hints_is_hidden" in cache dir
 
134
 * and restart unity8-dash. Restart is needed because the incoming canned
 
135
 * query tends to persist, so once the user has dimissed hints quickstart
 
136
 * and that signal was sent via the canned query user_data, it sticks around
 
137
 */
 
138
    if (hide_hints_quickstart)
 
139
    {
 
140
        show_normal = true;
 
141
        if (!hints_hidden())// checks for "hints_is_hidden" cache file
 
142
            dismiss_hints_quickstart();// write "hints_is_hidden" cache file
 
143
    } else {
 
144
        if (hints_hidden())// checks for "hints_is_hidden" cache file
 
145
        {
 
146
            qDebug() << "=== HINTS CASE 3";
 
147
            show_normal = true; 
 
148
        } else {
 
149
            qDebug() << "=== HINTS CASE 4";
 
150
            show_normal = false; 
 
151
        }
 
152
    }
 
153
 
 
154
    if (!show_normal)
 
155
    {
 
156
        qDebug() << "==== HINTS. show_normal is FALSE, show hints"; 
 
157
        if (uses_hints && hints_quickstart && hints_exists()) {
 
158
            display_hints_quickstart(upstream_reply);
 
159
            return;
 
160
        }
122
161
    }
123
162
 
124
163
    bool has_network = true;