feat: realtime comments (#1144)

* init

* fix: close bubblemenu after comment and wait before scroll

* scroll to comment when click

* highlight comment animation
This commit is contained in:
fuscodev
2025-05-16 17:18:23 +02:00
committed by GitHub
parent 00f4588c21
commit 1413033568
9 changed files with 96 additions and 12 deletions

View File

@ -7,6 +7,11 @@ export type InvalidateEvent = {
id?: string;
};
export type InvalidateCommentsEvent = {
operation: "invalidateComment";
pageId: string;
};
export type UpdateEvent = {
operation: "updateOne";
spaceId: string;
@ -52,4 +57,4 @@ export type DeleteTreeNodeEvent = {
}
};
export type WebSocketEvent = InvalidateEvent | UpdateEvent | DeleteEvent | AddTreeNodeEvent | MoveTreeNodeEvent | DeleteTreeNodeEvent;
export type WebSocketEvent = InvalidateEvent | InvalidateCommentsEvent | UpdateEvent | DeleteEvent | AddTreeNodeEvent | MoveTreeNodeEvent | DeleteTreeNodeEvent;

View File

@ -3,6 +3,7 @@ import { socketAtom } from "@/features/websocket/atoms/socket-atom.ts";
import { useAtom } from "jotai";
import { useQueryClient } from "@tanstack/react-query";
import { WebSocketEvent } from "@/features/websocket/types";
import { RQ_KEY } from "../comment/queries/comment-query";
export const useQuerySubscription = () => {
const queryClient = useQueryClient();
@ -21,6 +22,11 @@ export const useQuerySubscription = () => {
queryKey: [...data.entity, data.id].filter(Boolean),
});
break;
case "invalidateComment":
queryClient.invalidateQueries({
queryKey: RQ_KEY(data.pageId),
});
break;
case "updateOne":
entity = data.entity[0];
if (entity === "pages") {