mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-26 02:21:06 -04:00
* 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
24 lines
736 B
TypeScript
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
|
|
}
|