feat(chat): implement pull-to-refresh functionality and pagination for chat history
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { ChatSendResponse } from "@/data/dto/chat";
|
||||
import type { ChatState } from "@/stores/chat/chat-state";
|
||||
import {
|
||||
applyNetworkHistoryLoadedOutput,
|
||||
applyHttpSendOutput,
|
||||
countLockedHistoryMessages,
|
||||
localMessagesToUi,
|
||||
@@ -40,6 +41,10 @@ function makeChatState(overrides: Partial<ChatState> = {}): ChatState {
|
||||
requiredCredits: 0,
|
||||
shortfallCredits: 0,
|
||||
historyLoaded: true,
|
||||
historyTotal: 0,
|
||||
historyLimit: 50,
|
||||
nextHistoryOffset: 0,
|
||||
isLoadingMoreHistory: false,
|
||||
paymentUnlockPending: false,
|
||||
unlockHistoryPromptVisible: false,
|
||||
lockedHistoryCount: 0,
|
||||
@@ -244,6 +249,21 @@ describe("applyHttpSendOutput", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("chat history pagination helpers", () => {
|
||||
it("falls back to the bounded history limit when the backend limit is zero", () => {
|
||||
const nextState = applyNetworkHistoryLoadedOutput(makeChatState(), {
|
||||
messages: [],
|
||||
localCount: 0,
|
||||
total: 120,
|
||||
limit: 0,
|
||||
});
|
||||
|
||||
expect(nextState.historyLimit).toBe(50);
|
||||
expect(nextState.nextHistoryOffset).toBe(50);
|
||||
expect(nextState.historyTotal).toBe(120);
|
||||
});
|
||||
});
|
||||
|
||||
describe("localMessagesToUi", () => {
|
||||
it("maps locked voice messages from history", () => {
|
||||
const [message] = localMessagesToUi([
|
||||
|
||||
Reference in New Issue
Block a user