feat: add optimistic update for away status toggling#10395
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@O4epegb is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for following the naming conventions! 🙏 |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
| const { t } = useLocale(); | ||
| const { data: user } = useMeQuery(); | ||
| const { data: avatar } = useAvatarQuery(); | ||
| const utils = trpc.useContext(); |
There was a problem hiding this comment.
Just moved it up top to clearly see where it comes from before using
| const utils = trpc.useContext(); | ||
| const [helpOpen, setHelpOpen] = useState(false); | ||
| const [menuOpen, setMenuOpen] = useState(false); | ||
| if (!user) { |
There was a problem hiding this comment.
Duplicated check, there is already another one later on
| )} | ||
| onClick={() => { | ||
| mutation.mutate({ away: !user?.away }); | ||
| utils.viewer.me.invalidate(); |
There was a problem hiding this comment.
Invalidation happens inside of mutation now
sean-brydon
left a comment
There was a problem hiding this comment.
Works as expected! Nice work.
Udit-takkar
left a comment
There was a problem hiding this comment.
@O4epegb some E2E tests are failing
Missed this sorry! |
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
What does this PR do?
Adds optimistic update for away status toggling
Fixes #7749
Type of change
How should this be tested?
Just open dropdown user menu and toggle your away status. It should be toggled instantly/optimistically. If there is an error then the toast will be shown.
Mandatory Tasks
/claim #7749