feat:为减轻服务器压力,临时关闭实时订阅 user 表
This commit is contained in:
47
app/page.jsx
47
app/page.jsx
@@ -2082,29 +2082,30 @@ export default function HomePage() {
|
|||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
// 实时同步
|
||||||
if (!isSupabaseConfigured || !user?.id) return;
|
// useEffect(() => {
|
||||||
const channel = supabase
|
// if (!isSupabaseConfigured || !user?.id) return;
|
||||||
.channel(`user-configs-${user.id}`)
|
// const channel = supabase
|
||||||
.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'user_configs', filter: `user_id=eq.${user.id}` }, async (payload) => {
|
// .channel(`user-configs-${user.id}`)
|
||||||
const incoming = payload?.new?.data;
|
// .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'user_configs', filter: `user_id=eq.${user.id}` }, async (payload) => {
|
||||||
if (!isPlainObject(incoming)) return;
|
// const incoming = payload?.new?.data;
|
||||||
const incomingComparable = getComparablePayload(incoming);
|
// if (!isPlainObject(incoming)) return;
|
||||||
if (!incomingComparable || incomingComparable === lastSyncedRef.current) return;
|
// const incomingComparable = getComparablePayload(incoming);
|
||||||
await applyCloudConfig(incoming, payload.new.updated_at);
|
// if (!incomingComparable || incomingComparable === lastSyncedRef.current) return;
|
||||||
})
|
// await applyCloudConfig(incoming, payload.new.updated_at);
|
||||||
.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'user_configs', filter: `user_id=eq.${user.id}` }, async (payload) => {
|
// })
|
||||||
const incoming = payload?.new?.data;
|
// .on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'user_configs', filter: `user_id=eq.${user.id}` }, async (payload) => {
|
||||||
if (!isPlainObject(incoming)) return;
|
// const incoming = payload?.new?.data;
|
||||||
const incomingComparable = getComparablePayload(incoming);
|
// if (!isPlainObject(incoming)) return;
|
||||||
if (!incomingComparable || incomingComparable === lastSyncedRef.current) return;
|
// const incomingComparable = getComparablePayload(incoming);
|
||||||
await applyCloudConfig(incoming, payload.new.updated_at);
|
// if (!incomingComparable || incomingComparable === lastSyncedRef.current) return;
|
||||||
})
|
// await applyCloudConfig(incoming, payload.new.updated_at);
|
||||||
.subscribe();
|
// })
|
||||||
return () => {
|
// .subscribe();
|
||||||
supabase.removeChannel(channel);
|
// return () => {
|
||||||
};
|
// supabase.removeChannel(channel);
|
||||||
}, [user?.id]);
|
// };
|
||||||
|
// }, [user?.id]);
|
||||||
|
|
||||||
const handleSendOtp = async (e) => {
|
const handleSendOtp = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user