feat: lang specific trending

This commit is contained in:
Kieran 2023-11-10 09:54:08 +00:00
parent 98f6a686b0
commit 70fd872848
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 8 additions and 2 deletions

View File

@ -6,15 +6,17 @@ import PageSpinner from "Element/PageSpinner";
import Note from "Element/Event/Note";
import NostrBandApi from "External/NostrBand";
import { ErrorOrOffline } from "Element/ErrorOrOffline";
import { useLocale } from "IntlProvider";
export default function TrendingNotes() {
const [posts, setPosts] = useState<Array<NostrEvent>>();
const [error, setError] = useState<Error>();
const { lang } = useLocale();
const related = useReactions("trending", posts?.map(a => NostrLink.fromEvent(a)) ?? [], undefined, true);
async function loadTrendingNotes() {
const api = new NostrBandApi();
const trending = await api.trendingNotes();
const trending = await api.trendingNotes(lang);
setPosts(trending.notes.map(a => a.event));
}

View File

@ -44,7 +44,11 @@ export default class NostrBandApi {
return await this.#json<TrendingUserResponse>("GET", "/v0/trending/profiles");
}
async trendingNotes() {
async trendingNotes(lang?: string) {
const supportedLangs = ["en", "de", "ja", "zh", "th", "pt", "es", "fr"];
if (lang && supportedLangs.includes(lang)) {
return await this.#json<TrendingNoteResponse>("GET", `/v0/trending/notes?lang=${lang}`);
}
return await this.#json<TrendingNoteResponse>("GET", "/v0/trending/notes");
}