Files
Compass/web/lib/supabase/private-messages.ts
Martin Braquet ba9b3cfb06 Add pretty formatting (#29)
* Test

* Add pretty formatting

* Fix Tests

* Fix Tests

* Fix Tests

* Fix

* Add pretty formatting fix

* Fix

* Test

* Fix tests

* Clean typeckech

* Add prettier check

* Fix api tsconfig

* Fix api tsconfig

* Fix tsconfig

* Fix

* Fix

* Prettier
2026-02-20 17:32:27 +01:00

24 lines
736 B
TypeScript

import {run} from 'common/supabase/utils'
import {api} from 'web/lib/api'
import {db} from 'web/lib/supabase/db'
// NOTE: must be authorized (useIsAuthorized) to use this function
export const getSortedChatMessageChannels = async (limit: number, channelId?: number) => {
return await api('get-channel-memberships', {limit, channelId})
}
export type PrivateMessageMembership = {
user_id: string
channel_id: number
}
// NOTE: must be authorized (useIsAuthorized) to use this function
export const getTotalChatMessages = async (channelId: number) => {
const q = db
.from('private_user_messages')
.select('*', {head: true, count: 'exact'})
.eq('channel_id', channelId)
const {count} = await run(q)
return count
}