oh my god this is so hard

This commit is contained in:
2024-10-22 16:38:06 -05:00
parent f48ec76cba
commit c0ebccf6b1
8 changed files with 1444 additions and 1318 deletions

View File

@ -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, {