Skip to content

Commit aeee128

Browse files
committed
feat: [#796] new function wrapper for getting all user profiles from the API
1 parent 6e008e9 commit aeee128

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

composables/states.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PublicSettings, Category, TokenResponse, TorrentTag } from "torrust-index-types-lib";
1+
import type { PublicSettings, Category, TokenResponse, TorrentTag, UserProfile } from "torrust-index-types-lib";
22
import { Rest } from "torrust-index-api-lib";
33
import { notify } from "notiwind-ts";
44
import { useRuntimeConfig, useState } from "#imports";
@@ -8,6 +8,7 @@ export const useCategories = () => useState<Array<Category>>("categories", () =>
88
export const useTags = () => useState<Array<TorrentTag>>("tags", () => new Array<TorrentTag>());
99
export const useSettings = () => useState<PublicSettings>("public-settings", () => null);
1010
export const useUser = () => useState<TokenResponse>("user", () => null);
11+
export const useUserProfiles = () => useState<Array<UserProfile>>("user-profiles", () => new Array<UserProfile>());
1112

1213
export function getSettings () {
1314
useRestApi().value.settings.getPublicSettings()
@@ -94,3 +95,17 @@ export async function getUser () {
9495
}, 10000);
9596
});
9697
}
98+
99+
export function getUserProfiles () {
100+
useRestApi().value.user.getUserProfiles()
101+
.then((res) => {
102+
useUserProfiles().value = res;
103+
})
104+
.catch((err) => {
105+
notify({
106+
group: "error",
107+
title: "Error",
108+
text: `Trying to get user profiles. ${err.message}.`
109+
}, 10000);
110+
});
111+
}

0 commit comments

Comments
 (0)