Skip to content

Commit

Permalink
Merge pull request #5 from deepsingh132/development
Browse files Browse the repository at this point in the history
Update framer-motion to v11.0.6 from v6.3.3 fixing post state update on feed type change
  • Loading branch information
deepsingh132 authored Feb 27, 2024
2 parents 5d0dc70 + 520c393 commit e4c9493
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 152 deletions.
69 changes: 34 additions & 35 deletions components/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default function Feed({ type }) {
// refreshInterval: 30000,
revalidateOnFocus: false,
revalidateOnReconnect: true,
refreshWhenOffline: true,
});

const [modalOpen, setModalOpen] = useState(false);
Expand Down Expand Up @@ -97,13 +96,13 @@ export default function Feed({ type }) {
}
if (operation === "reply") {
mutate({
posts: data?.posts.map((post: any) => {
if (post._id === id) {
post.comments?.push(newPost);
}
return post;
}),
},
posts: data?.posts.map((post: any) => {
if (post._id === id) {
post.comments?.push(newPost);
}
return post;
}),
},
{
revalidate: false,
rollbackOnError: true,
Expand Down Expand Up @@ -185,33 +184,33 @@ export default function Feed({ type }) {

<AnimatePresence>
{data?.posts
?.slice(0, 40)
.sort(
(
a: { createdAt: string | number | Date },
b: { createdAt: string | number | Date }
) => {
const dateA = new Date(a.createdAt) as any;
const dateB = new Date(b.createdAt) as any;
return dateB - dateA; // Sort in descending order
}
)
.map((post: { _id: Key | null | undefined }) => (
<motion.div
key={post._id}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 1 }}
>
<Post
key={post?._id}
id={post?._id}
post={post}
updatePosts={updatePosts}
/>
</motion.div>
))}
?.slice(0, 40)
.sort(
(
a: { createdAt: string | number | Date },
b: { createdAt: string | number | Date }
) => {
const dateA = new Date(a.createdAt) as any;
const dateB = new Date(b.createdAt) as any;
return dateB - dateA; // Sort in descending order
}
)
.map((post: { _id: Key | null | undefined }) => (
<motion.div
key={post._id}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 1 }}
>
<Post
key={post?._id}
id={post?._id}
post={post}
updatePosts={updatePosts}
/>
</motion.div>
))}
</AnimatePresence>

{modalOpen && (
Expand Down
144 changes: 28 additions & 116 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@heroicons/react": "^2.0.18",
"@react-google-maps/api": "^2.19.2",
"axios": "^1.5.0",
"framer-motion": "^6.3.3",
"framer-motion": "11.0.6",
"jose": "^4.14.6",
"jsonwebtoken": "^9.0.2",
"moment": "^2.29.3",
Expand Down

0 comments on commit e4c9493

Please sign in to comment.