diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index d074416..98af06a 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -37,7 +37,26 @@ export default function ChatFragment({ target, ...props }: Args) { setChatInfo(re.data as Chat) }, [target]) - console.log(tabItemSelected) + let page = 0 + async function loadMore() { + const re = await Client.invoke("Chat.getMessageHistory", { + token: data.access_token, + target, + page, + }) + + if (checkApiSuccessOrSncakbar(re, "拉取歷史記錄失敗")) return + page++ + setMessagesList(messagesList.concat()) + } + + React.useEffect(() => { + + return () => { + + } + }) + return (
{ - if (this.checkArgsMissing(args, ['token', 'target'])) return { + if (this.checkArgsMissing(args, ['token', 'target', 'page'])) return { msg: "參數缺失", code: 400, } @@ -93,9 +94,18 @@ export default class ChatApi extends BaseApi { msg: "令牌無效", } + const chat = Chat.findById(args.target as string) + if (chat == null) return { + code: 404, + msg: "對話不存在", + } + return { - code: 501, - msg: "未實現", + code: 200, + msg: "成功", + data: { + messages: MessagesManager.getInstanceForChat(chat).getMessagesWithPage(), + }, } }) }