Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7028d27a authored by Fabrice Di Meglio's avatar Fabrice Di Meglio Committed by Android (Google) Code Review
Browse files

Merge "Fix bug #14494292 Settings>Search>Recent searches keep on populating...

Merge "Fix bug #14494292 Settings>Search>Recent searches keep on populating the same keyword if it is searched again"
parents d6014e51 b58b28e1
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1217,9 +1217,16 @@ public class Index {

            long lastInsertedRowId = -1;
            try {
                // First, delete all saved queries that are the same
                database.delete(Tables.TABLE_SAVED_QUERIES,
                        IndexDatabaseHelper.SavedQueriesColums.QUERY + " = ?",
                        new String[] { params[0] });

                // Second, insert the saved query
                lastInsertedRowId =
                        database.replaceOrThrow(Tables.TABLE_SAVED_QUERIES, null, values);
                        database.insertOrThrow(Tables.TABLE_SAVED_QUERIES, null, values);

                // Last, remove "old" saved queries
                final long delta = lastInsertedRowId - MAX_SAVED_SEARCH_QUERY;
                if (delta > 0) {
                    int count = database.delete(Tables.TABLE_SAVED_QUERIES, "rowId <= ?",