fix(betterActivities): avoid conditional hook calls

Prevents crashing when the activities length changes
This commit is contained in:
Nico 2024-08-02 10:14:35 +02:00 committed by GitHub
parent 32476dd1df
commit 57c8f6915c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -154,8 +154,6 @@ export default definePlugin({
setCurrentActivity(activities[0]);
}, [activities]);
if (!activities.length) return null;
// we use these for other activities, it would be better to somehow get the corresponding activity props
const generalProps = useMemo(() => Object.keys(props).reduce((acc, key) => {
// exclude activity specific props to prevent copying them to all activities (e.g. buttons)
@ -163,6 +161,9 @@ export default definePlugin({
return acc;
}, {} as Omit<typeof props, "renderActions" | "application">), [props]);
if (!activities.length) return null;
if (settings.store.allActivitiesStyle === "carousel") {
return (
<div style={{ display: "flex", flexDirection: "column" }}>