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

« back to all changes in this revision

Viewing changes to src/utils.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:
1278
1278
 
1279
1279
void Query::display_hints_quickstart(us::SearchReplyProxy const& upstream_reply_)
1280
1280
{
 
1281
 
1281
1282
    Category::SCPtr hint_cat;
1282
1283
    SearchMetadata metadata(search_metadata());
1283
1284
 
1290
1291
              metadata, reply);
1291
1292
}
1292
1293
 
1293
 
bool Query::is_hints_quickstart_dismissed(){
 
1294
bool Query::hints_hidden(){
1294
1295
 
1295
 
    auto filepath1 = QString::fromStdString(cache_dir_) +"/" + hints_is_hidden;
 
1296
    auto filepath1 = QString::fromStdString(cache_dir_) +"/" + hints_file;
1296
1297
    auto filepath2 = QString::fromStdString(cache_dir_) +"/" + firstboot;
1297
1298
    if (QFile::exists(filepath1) || QFile::exists(filepath2))
1298
1299
        return true;
1301
1302
}
1302
1303
 
1303
1304
void Query::dismiss_hints_quickstart() {
1304
 
    auto filepath= QString::fromStdString(cache_dir_) +"/" + hints_is_hidden;
 
1305
    qDebug() << "==== HINTS in dismiss()";
 
1306
    auto filepath= QString::fromStdString(cache_dir_) +"/" + hints_file;
1305
1307
    QFile file(filepath);
1306
1308
    file.open(QIODevice::WriteOnly);
1307
 
    QString msg = QString("Timestamp for %1").arg(qstr(HINTS_THIS_SCOPE));
 
1309
    QString msg = QString("Timestamp for %1 %2").arg(qstr(HINTS_THIS_SCOPE), QDateTime::currentDateTime().toString());
1308
1310
    file.write(sstr(msg).c_str(), sstr(msg).size());
1309
1311
    file.close();
1310
1312
}