|
1 |
| -import { Avatar, Button, Menu } from '@/ui' |
| 1 | +import { Avatar, Menu } from '@/ui' |
2 | 2 | import React, { useRef, useState } from 'react'
|
3 | 3 | import { Markdown, A, LikeModal, useLikes, EditComment } from '@/components'
|
4 | 4 | import { DateTime } from 'luxon'
|
5 |
| -import { UpdateCommentType } from 'src/pages' |
| 5 | +import { HomePageFeedUpdateType, UpdateCommentType } from 'src/pages' |
6 | 6 | import { useSession } from 'next-auth/client'
|
7 | 7 | import classNames from 'classnames'
|
8 | 8 | import {
|
@@ -72,7 +72,21 @@ export default function UpdateComment({
|
72 | 72 | id: toastId.current,
|
73 | 73 | icon: <Trash className="text-danger-400" />,
|
74 | 74 | })
|
75 |
| - queryClient.refetchQueries('/api/fauna/all-updates') |
| 75 | + if (queryClient.getQueryState('/api/fauna/all-updates')) { |
| 76 | + queryClient.setQueryData<{ updates: HomePageFeedUpdateType[] }>( |
| 77 | + '/api/fauna/all-updates', |
| 78 | + (oldData) => ({ |
| 79 | + updates: oldData.updates.map((_update) => { |
| 80 | + if (_update.id === comment.updateId) { |
| 81 | + _update.comments.data = _update.comments.data.filter( |
| 82 | + (_comment) => _comment.id !== comment.id |
| 83 | + ) |
| 84 | + } |
| 85 | + return _update |
| 86 | + }), |
| 87 | + }) |
| 88 | + ) |
| 89 | + } |
76 | 90 | },
|
77 | 91 | onError: () => {
|
78 | 92 | toast.error('Something went wrong!!!', {
|
|
0 commit comments