feat(frontend): show next_expected_seq and page continuity hints
This commit is contained in:
@@ -10,12 +10,19 @@ type MessageItem = {
|
|||||||
isDeleted?: boolean
|
isDeleted?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PageInfo = {
|
||||||
|
nextExpectedSeq?: number
|
||||||
|
highestCommittedSeq?: number
|
||||||
|
hasMore?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export default function ChatPage() {
|
export default function ChatPage() {
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const guildId = searchParams.get('guildId') ?? ''
|
const guildId = searchParams.get('guildId') ?? ''
|
||||||
const [channelId, setChannelId] = useState(() => searchParams.get('channelId') ?? '')
|
const [channelId, setChannelId] = useState(() => searchParams.get('channelId') ?? '')
|
||||||
const [content, setContent] = useState('')
|
const [content, setContent] = useState('')
|
||||||
const [messages, setMessages] = useState<MessageItem[]>([])
|
const [messages, setMessages] = useState<MessageItem[]>([])
|
||||||
|
const [pageInfo, setPageInfo] = useState<PageInfo | null>(null)
|
||||||
const [socketState, setSocketState] = useState<'offline' | 'online'>('offline')
|
const [socketState, setSocketState] = useState<'offline' | 'online'>('offline')
|
||||||
const [seqFrom, setSeqFrom] = useState('1')
|
const [seqFrom, setSeqFrom] = useState('1')
|
||||||
const [seqTo, setSeqTo] = useState('999999')
|
const [seqTo, setSeqTo] = useState('999999')
|
||||||
@@ -55,6 +62,7 @@ export default function ChatPage() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
setMessages(res.data.items ?? [])
|
setMessages(res.data.items ?? [])
|
||||||
|
setPageInfo(res.data.page ?? null)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendMessage() {
|
async function sendMessage() {
|
||||||
@@ -133,6 +141,12 @@ export default function ChatPage() {
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
{pageInfo ? (
|
||||||
|
<p>
|
||||||
|
next_expected_seq: {pageInfo.nextExpectedSeq ?? '-'} | highest_committed_seq:{' '}
|
||||||
|
{pageInfo.highestCommittedSeq ?? '-'} | has_more: {String(pageInfo.hasMore ?? false)}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user