Skip to content

Commit

Permalink
fix: last N trending topics
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisParedes1 committed Dec 7, 2023
1 parent 721f113 commit 430bc38
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/screens/search/search-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import { Text, TouchableOpacity, View } from '@/ui';
import UserList from '../users/user-list';
import { SearchBar } from './search-bar';

const LAST_N_TRENDING_TOPICS = 10;

type TrendingTopic = {
id: string;
name: string;
created_at: string;
};

const SearchView = () => {
Expand Down Expand Up @@ -50,12 +53,19 @@ const SearchView = () => {
navigate('SnapList', { snaps });
};

const recentTrends = trendingTopics
.sort(
(a, b) =>
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
)
.slice(0, LAST_N_TRENDING_TOPICS);

const renderTrendingTopics = () => (
<>
<SearchBar />
<View className="flex flex-row flex-wrap p-4">
<Text className="w-full text-lg font-bold">Trending Topics</Text>
{trendingTopics.map((topic) => (
{recentTrends.map((topic) => (
<TouchableOpacity
key={topic.id}
onPress={() => handleTopicSelect(topic)}
Expand Down

0 comments on commit 430bc38

Please sign in to comment.