add load more button on snapshot array

This commit is contained in:
Simon 2025-12-26 14:44:10 +07:00
parent 83280ddcc9
commit 7fa776a919
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 15 additions and 6 deletions

View File

@ -33,6 +33,7 @@ const SettingsApplication = () => {
const { userConfig } = useUserConfigStore();
const [response, setResponse] = useState<SettingsApplicationReponses>();
const [refresh, setRefresh] = useState(false);
const [visibleSnapshotCount, setVisibleSnapshotCount] = useState(10);
const snapshots = response?.snapshots;
const appSettingsConfig = response?.appSettingsConfig;
@ -976,10 +977,9 @@ const SettingsApplication = () => {
</p>
<br />
{restoringSnapshot && <p>Snapshot restore started</p>}
{!restoringSnapshot &&
snapshots.snapshots &&
snapshots.snapshots.map(snapshot => {
return (
{!restoringSnapshot && snapshots.snapshots && (
<>
{snapshots.snapshots?.slice(0, visibleSnapshotCount).map(snapshot => (
<p key={snapshot.id}>
<Button
label="Restore"
@ -994,8 +994,17 @@ const SettingsApplication = () => {
<span className="settings-current">{snapshot.duration_s}s</span> to
create. State: <i>{snapshot.state}</i>
</p>
);
})}
))}
{visibleSnapshotCount < snapshots.snapshots.length && (
<Button
label="Load More"
onClick={() => {
setVisibleSnapshotCount(visibleSnapshotCount + 10);
}}
/>
)}
</>
)}
</>
)}
</div>