Increment version to 2.14.1 and refactor notifications stream hook

- Bumped package version in package.json from 2.14.0 to 2.14.1.
- Refactored the `useNotificationsStream` hook to remove unnecessary `useQuery` and streamline the subscription logic for real-time notifications, enhancing performance and clarity.
This commit is contained in:
gbuomprisco
2025-09-17 12:48:42 +08:00
parent 533dfba5b9
commit 530e127000
2 changed files with 20 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "next-supabase-saas-kit-turbo",
"version": "2.14.0",
"version": "2.14.1",
"private": true,
"sideEffects": false,
"engines": {

View File

@@ -1,7 +1,5 @@
import { useEffect } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useSupabase } from '@kit/supabase/hooks/use-supabase';
type Notification = {
@@ -20,13 +18,10 @@ export function useNotificationsStream(params: {
}) {
const client = useSupabase();
const { data: subscription } = useQuery({
enabled: params.enabled,
queryKey: ['realtime-notifications', ...params.accountIds],
queryFn: () => {
useEffect(() => {
const channel = client.channel('notifications-channel');
return channel
const subscription = channel
.on(
'postgres_changes',
{
@@ -36,16 +31,14 @@ export function useNotificationsStream(params: {
table: 'notifications',
},
(payload) => {
console.log('payload', payload);
params.onNotifications([payload.new as Notification]);
},
)
.subscribe();
},
});
useEffect(() => {
return () => {
void subscription?.unsubscribe();
};
}, [subscription]);
}, [client, params]);
}