enh/refac: channels message lazy load data

This commit is contained in:
Timothy Jaeryang Baek
2025-12-03 17:52:44 -05:00
parent 133618aaf0
commit 54b7ec56d6
4 changed files with 118 additions and 5 deletions
+38
View File
@@ -491,6 +491,44 @@ export const getChannelThreadMessages = async (
return res;
};
export const getMessageData = async (
token: string = '',
channel_id: string,
message_id: string
) => {
let error = null;
const res = await fetch(
`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages/${message_id}/data`,
{
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
authorization: `Bearer ${token}`
}
}
)
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err.detail;
console.error(err);
return null;
});
if (error) {
throw error;
}
return res;
};
type MessageForm = {
temp_id?: string;
reply_to_id?: string;