Skip to content

Commit 7f51734

Browse files
committed
Fix Profile list
1 parent e5f189a commit 7f51734

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

example/next-storage/components/ProfileList.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ export default function ProfileList() {
1414

1515
realtimeProfiles = supabase
1616
.from('profiles')
17-
.on('*', (payload: SupabaseRealtimePayload<Profile>) => {
18-
console.log('profiles', profiles)
19-
const otherProfiles = profiles?.filter((x) => x.id != payload.new.id)
20-
console.log('otherProfiles', otherProfiles)
21-
setProfiles([payload.new, ...otherProfiles])
22-
})
17+
.on('*', (payload: SupabaseRealtimePayload<Profile>) => profileUpdated(payload.new))
2318
.subscribe()
2419

2520
return () => {
@@ -28,6 +23,11 @@ export default function ProfileList() {
2823
}
2924
}, [])
3025

26+
function profileUpdated(profile: Profile) {
27+
const otherProfiles = profiles?.filter((x) => x.id != profile.id)
28+
setProfiles([profile, ...otherProfiles])
29+
}
30+
3131
async function getPublicProfiles() {
3232
try {
3333
const { data, error } = await supabase

0 commit comments

Comments
 (0)