Skip to content

Commit

Permalink
Add activity whitelist to filter displayed activities
Browse files Browse the repository at this point in the history
  • Loading branch information
upayanmazumder committed Jan 6, 2025
1 parent cbe38ef commit 51d86af
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions app/src/components/activity/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const formatElapsedTime = (startTimestamp) => {

const Activity = () => {
const [guildStatistics, setGuildStatistics] = useState(null);
const activityWhitelist = ['Spotify', 'Visual Studio Code'];

useEffect(() => {
const fetchData = async () => {
Expand All @@ -58,35 +59,35 @@ const Activity = () => {
}

return (
<div class={activityStyles.activities}>
<div className={activityStyles.activities}>
{guildStatistics.map((guild, guildIndex) => (
<div key={guildIndex}>
<div class={activityStyles.status}>
<div className={activityStyles.status}>
{getStatusIcon(guild.discordstatus)} <span>{guild.discordstatus}</span>
</div>
<ul>
{guild.activities.map((activity, activityIndex) => (
<div key={activityIndex} class={activityStyles.activity}>
{activity.largeImageURL && (
<img
src={activity.largeImageURL}
alt={activity.largeText}

/>
)}
<h3>{activity.name}</h3>
<p>{activity.details}</p>
<p>{activity.state}</p>
<p>
{formatElapsedTime(activity.startTimestamp)}
</p>
</div>
))}
{guild.activities
.filter(activity => activityWhitelist.includes(activity.name))
.map((activity, activityIndex) => (
<div key={activityIndex} className={activityStyles.activity}>
{activity.largeImageURL && (
<img
src={activity.largeImageURL}
alt={activity.largeText}
/>
)}
<h3>{activity.name}</h3>
<p>{activity.details}</p>
<p>{activity.state}</p>
<p>
{formatElapsedTime(activity.startTimestamp)}
</p>
</div>
))}
</ul>
</div>
))
}
</div >
))}
</div>
);
};

Expand Down

0 comments on commit 51d86af

Please sign in to comment.