mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Sort recent searches by search time.
This commit is contained in:
parent
31d7592964
commit
bc9cfc8183
@ -351,6 +351,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||
"username TEXT NOT NULL, subreddit_name TEXT NOT NULL, " +
|
||||
"PRIMARY KEY(path, username, subreddit_name), FOREIGN KEY(path) REFERENCES multi_reddits(path) ON DELETE CASCADE ON UPDATE CASCADE, " +
|
||||
"FOREIGN KEY(username) REFERENCES multi_reddits(username) ON DELETE CASCADE ON UPDATE CASCADE)");
|
||||
database.execSQL("ALTER TABLE recent_search_queries ADD COLUMN time INTEGER DEFAULT 0 NOT NULL");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -17,10 +17,13 @@ public class RecentSearchQuery {
|
||||
@NonNull
|
||||
@ColumnInfo(name = "search_query")
|
||||
private String searchQuery;
|
||||
@ColumnInfo(name = "time")
|
||||
private long time;
|
||||
|
||||
public RecentSearchQuery(@NonNull String username, @NonNull String searchQuery) {
|
||||
this.username = username;
|
||||
this.searchQuery = searchQuery;
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -40,4 +43,12 @@ public class RecentSearchQuery {
|
||||
public void setSearchQuery(@NonNull String searchQuery) {
|
||||
this.searchQuery = searchQuery;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ public interface RecentSearchQueryDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insert(RecentSearchQuery recentSearchQuery);
|
||||
|
||||
@Query("SELECT * FROM recent_search_queries WHERE username = :username")
|
||||
@Query("SELECT * FROM recent_search_queries WHERE username = :username ORDER BY time DESC")
|
||||
LiveData<List<RecentSearchQuery>> getAllRecentSearchQueriesLiveData(String username);
|
||||
|
||||
@Query("SELECT * FROM recent_search_queries WHERE username = :username")
|
||||
@Query("SELECT * FROM recent_search_queries WHERE username = :username ORDER BY time DESC")
|
||||
List<RecentSearchQuery> getAllRecentSearchQueries(String username);
|
||||
|
||||
@Delete
|
||||
|
Loading…
Reference in New Issue
Block a user