Front: Merge

This commit is contained in:
Arthur Jamet
2023-05-08 12:55:16 +01:00
5 changed files with 86 additions and 23 deletions
+10 -8
View File
@@ -13,6 +13,7 @@ import { en } from "./i18n/Translations";
import { QueryClient } from "react-query";
import UserSettings from "./models/UserSettings";
import { PartialDeep } from "type-fest";
import SearchHistory from "./models/SearchHistory";
type AuthenticationInput = { username: string; password: string };
type RegistrationInput = AuthenticationInput & { email: string };
@@ -364,15 +365,16 @@ export default class API {
* Retrieve the authenticated user's search history
* @param lessonId the id to find the lesson
*/
public static async getSearchHistory(): Promise<Song[]> {
const queryClient = new QueryClient();
let songs = await queryClient.fetchQuery(
["API", "allsongs"],
API.getAllSongs
);
const shuffled = [...songs].sort(() => 0.5 - Math.random());
public static async getSearchHistory(): Promise<SearchHistory[]> {
const tmp = await this.fetch({
route: "/history/search",
});
return shuffled.slice(0, 2);
return tmp.map((value: any) => ({
query: value.query,
userID: value.userId,
id: value.id,
}));
}
/**