File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {insert} from 'shared/supabase/utils'
1414import { convertPrivateUser , convertUser } from 'common/supabase/users'
1515import { getBucket } from "shared/firebase-utils" ;
1616import { sendWelcomeEmail } from "email/functions/helpers" ;
17+ import { setLastOnlineTimeUser } from "api/set-last-online-time" ;
1718
1819export const createUser : APIHandler < 'create-user' > = async (
1920 props ,
@@ -134,6 +135,11 @@ export const createUser: APIHandler<'create-user'> = async (
134135 } catch ( e ) {
135136 console . error ( 'Failed to sendWelcomeEmail' , e )
136137 }
138+ try {
139+ await setLastOnlineTimeUser ( auth . uid )
140+ } catch ( e ) {
141+ console . error ( 'Failed to set last online time' , e )
142+ }
137143 }
138144
139145 return {
Original file line number Diff line number Diff line change @@ -6,7 +6,12 @@ export const setLastOnlineTime: APIHandler<'set-last-online-time'> = async (
66 auth
77) => {
88 if ( ! auth || ! auth . uid ) return
9+ await setLastOnlineTimeUser ( auth . uid )
10+ // console.log('setLastOnline')
11+ }
912
13+
14+ export const setLastOnlineTimeUser = async ( userId : string ) => {
1015 const pg = createSupabaseDirectClient ( )
1116 await pg . none ( `
1217 INSERT INTO user_activity (user_id, last_online_time)
@@ -16,7 +21,6 @@ export const setLastOnlineTime: APIHandler<'set-last-online-time'> = async (
1621 SET last_online_time = EXCLUDED.last_online_time
1722 WHERE user_activity.last_online_time < now() - interval '1 minute';
1823 ` ,
19- [ auth . uid ]
24+ [ userId ]
2025 )
21- // console.log('setLastOnline')
2226}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export const useOnline = () => {
99 useEffect ( ( ) => {
1010 if ( ! profile || ! isAuthed ) return
1111 void ( async ( ) => {
12- const date = new Date ( ) . toISOString ( )
12+ // const date = new Date().toISOString()
1313 // const result = await run(
1414 // db
1515 // .from('profiles')
You can’t perform that action at this time.
0 commit comments