diff --git a/apps/client/src/widgets/type_widgets/options/backup.tsx b/apps/client/src/widgets/type_widgets/options/backup.tsx index e516edf82..ca69cf5e0 100644 --- a/apps/client/src/widgets/type_widgets/options/backup.tsx +++ b/apps/client/src/widgets/type_widgets/options/backup.tsx @@ -1,4 +1,4 @@ -import { BackupDatabaseNowResponse } from "@triliumnext/commons"; +import { BackupDatabaseNowResponse, DatabaseBackup } from "@triliumnext/commons"; import { t } from "../../../services/i18n"; import server from "../../../services/server"; import toast from "../../../services/toast"; @@ -8,12 +8,32 @@ import FormGroup from "../../react/FormGroup"; import FormText from "../../react/FormText"; import { useTriliumOptionBool } from "../../react/hooks"; import OptionsSection from "./components/OptionsSection"; +import { useCallback, useEffect, useState } from "preact/hooks"; +import { formatDateTime } from "../../../utils/formatters"; export default function BackupSettings() { + const [ backups, setBackups ] = useState([]); + + const refreshBackups = useCallback(() => { + server.get("database/backups").then((backupFiles) => { + // Sort the backup files by modification date & time in a desceding order + backupFiles.sort((a, b) => { + if (a.mtime < b.mtime) return 1; + if (a.mtime > b.mtime) return -1; + return 0; + }); + + setBackups(backupFiles); + }); + }, [ setBackups ]); + + useEffect(refreshBackups, []); + return ( <> - + + ) } @@ -50,7 +70,7 @@ export function AutomaticBackup() { ) } -export function BackupNow() { +export function BackupNow({ refreshCallback }: { refreshCallback: () => void }) { return (