Skip to content

Commit

Permalink
Don't overwrite watchlist (#3769) (#3796)
Browse files Browse the repository at this point in the history
* Don't overwrite empty watchlist (#3769)

* setWatchlist function

Co-authored-by: Joystream Stats <dev@joystreamstats.live>
  • Loading branch information
traumschule and Joystream Stats authored Dec 12, 2022
1 parent a591d7a commit 8a34719
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ui/src/forum/components/Thread/WatchlistButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export const WatchlistButton = ({ threadId }: Props) => {
const addToWatchlist = useCallback(
(e) => {
e.stopPropagation()
setWatchlist(watchlist ? [...watchlist, threadId] : [threadId])
setWatchlist((watchlist = []) => [...watchlist, threadId])
},
[watchlist]
)
const removeFromWatchlist = useCallback(
(e) => {
e.preventDefault()
setWatchlist(watchlist?.filter((id) => id !== threadId) ?? [])
setWatchlist((watchlist = []) => watchlist.filter((id) => id !== threadId))
},
[watchlist]
)
Expand Down

2 comments on commit 8a34719

@vercel
Copy link

@vercel vercel bot commented on 8a34719 Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 8a34719 Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pioneer-2 – ./

pioneer-2.vercel.app
pioneer-2-git-dev-joystream.vercel.app
pioneer-2-joystream.vercel.app

Please sign in to comment.