@@ -3,8 +3,10 @@ import {
33 ReactionStatus as ReactionStatusModel ,
44} from "@/backend/models/domain-models" ;
55import * as reactionActions from "@/backend/services/reaction.actions" ;
6+ import { useSession } from "@/store/session.atom" ;
67import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
78import React from "react" ;
9+ import { useLoginPopup } from "../app-login-popup" ;
810
911interface Props {
1012 resource_type : "ARTICLE" | "COMMENT" ;
@@ -26,6 +28,8 @@ export const ResourceReactionable: React.FC<Props> = ({
2628 render,
2729} ) => {
2830 const queryClient = useQueryClient ( ) ;
31+ const session = useSession ( ) ;
32+ const appLoginPopup = useLoginPopup ( ) ;
2933
3034 const query = useQuery ( {
3135 queryKey : [ "reaction" , resource_id , resource_type ] ,
@@ -41,6 +45,9 @@ export const ResourceReactionable: React.FC<Props> = ({
4145 reaction_type,
4246 } ) ,
4347 async onMutate ( reaction_type ) {
48+ if ( ! session ?. user ) {
49+ return appLoginPopup . show ( ) ;
50+ }
4451 await queryClient . cancelQueries ( {
4552 queryKey : [ "reaction" , resource_id , resource_type ] ,
4653 } ) ;
0 commit comments