forked from Kieran/snort
feat: lang specific trending
This commit is contained in:
parent
98f6a686b0
commit
70fd872848
@ -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));
|
||||
}
|
||||
|
||||
|
6
packages/app/src/External/NostrBand.ts
vendored
6
packages/app/src/External/NostrBand.ts
vendored
@ -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");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user