mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-25 03:16:37 -05:00
28 lines
770 B
TypeScript
28 lines
770 B
TypeScript
import { User } from 'common/user'
|
|
import { SupabaseDirectClient } from 'shared/supabase/init'
|
|
import {
|
|
broadcastUpdatedPrivateUser,
|
|
broadcastUpdatedUser,
|
|
} from 'shared/websockets/helpers'
|
|
import { DataUpdate, updateData } from './utils'
|
|
|
|
/** only updates data column. do not use for name, username */
|
|
export const updateUser = async (
|
|
db: SupabaseDirectClient,
|
|
id: string,
|
|
update: Partial<User>
|
|
) => {
|
|
const fullUpdate = { id, ...update }
|
|
await updateData(db, 'users', 'id', fullUpdate)
|
|
broadcastUpdatedUser(fullUpdate)
|
|
}
|
|
|
|
export const updatePrivateUser = async (
|
|
db: SupabaseDirectClient,
|
|
id: string,
|
|
update: DataUpdate<'private_users'>
|
|
) => {
|
|
await updateData(db, 'private_users', 'id', { id, ...update })
|
|
broadcastUpdatedPrivateUser(id)
|
|
}
|