oh my god this is so hard
This commit is contained in:
@ -195,11 +195,11 @@ export const sendRelationshipRequest = async (userId: number, targetUserId: numb
|
||||
}
|
||||
};
|
||||
|
||||
export const getInitialMessages = async (userId: number, limit: number = 20) => {
|
||||
export const getMessages = async (userId: number, limit: number = 20, offset: number = 0) => {
|
||||
if (!userId || isNaN(userId)) return;
|
||||
try {
|
||||
const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/messages/getInitialMessages`;
|
||||
const response = await fetch((apiUrl + `?userId=${userId}&limit=${limit}`), {
|
||||
const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/messages/get`;
|
||||
const response = await fetch((apiUrl+`?userId=${userId}&limit=${limit}&offset=${offset}`), {
|
||||
headers: {
|
||||
'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '',
|
||||
},
|
||||
@ -218,7 +218,6 @@ export const getInitialMessages = async (userId: number, limit: number = 20) =>
|
||||
};
|
||||
|
||||
export const sendMessage = async (message: Message) => {
|
||||
if (!message) return;
|
||||
try {
|
||||
const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/messages/send`;
|
||||
const response = await fetch(apiUrl, {
|
||||
|
Reference in New Issue
Block a user