acenturyandabit / acenturyandabit/workflowish
make a class in charge of handling the data;
- 主要語言
- TypeScript
- 星號
- 0
- 分支
- 1
- PR 合併指標
- 30 天內沒有已合併 PR
描述
this should just be a call to "saverClass.sync(props.saveSource)".
Same goes with other functions which handle data.
https://api.github.com/acenturyandabit/workflowish/blob/d01a875/src/Stores/FileDialog/index.tsx#L105
```javascript
import * as React from 'react';
import Button from '@mui/material/Button';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogTitle from '@mui/material/DialogTitle';
import Dialog from '@mui/material/Dialog';
import { KVStores, makeKVStore } from '~Stores';
import { Box, TextField, MenuItem, FormControlLabel, Checkbox } from "@mui/material"
import { KVStoresAndLoadedState } from '~Stores/KVStoreInstances';
import { BaseStoreDataType } from '~CoreDataLake';
import { KVStore, KVStoreSettingsStruct } from '~Stores/types';
const FileNavbarAndDialog = (props: {
setKVStores: React.Dispatch>,
kvStores: KVStoresAndLoadedState,
setData: React.Dispatch>,
data: BaseStoreDataType
}) => {
const [open, setOpen] = React.useState(false);
const [newSaveLocationType, setNewSaveLocationType] = React.useState(Object.keys(KVStores)[0]);
const bumpKVStore = () => {
props.setKVStores(kvStores => ({ ...kvStores }))
}
const addNewSaveSource = () => {
props.setKVStores(kvStores => ({
...kvStores, stores: [
...kvStores.stores,
makeKVStore(newSaveLocationType)
]
}))
}
const removeSaveSource = (idx: number) => {
props.setKVStores(kvStores => {
const newStores = [...kvStores.stores];
newStores.splice(idx, 1);
return {
...kvStores, stores: newStores
}
})
}
return
setOpen(false)}>
Save Sources
Registered save sources
{
props.setKVStores({
...props.kvStores,
autosaveOn: evt.target.checked
})
}}
>} label="Autosave">
{props.kvStores.stores.map((i, ii) => (
{i.makeFileDialog(bumpKVStore)}
removeSaveSource(ii)}
data={props.data}
setData={props.setData}
/>
))}
Or, add a new save source...
setNewSaveLocationType(evt.target.value)}
value={newSaveLocationType}
sx={{ mb: 2 }}
>
{Object.values(KVStores).map(i => ({i.type}))}
Add new save source
setOpen(false)}>Close
setOpen(true)}>File
}
const SaveLoadButtons = (props: {
saveSource: KVStore,
removeSaveSource: () => void
data: BaseStoreDataType,
setData: React.Dispatch>,
}) => {
const syncFn = props.saveSource.sync;
const SyncButton = syncFn ? {
(async () => {
const newData = await syncFn(props.data)
// TODO: make a class in charge of handling the data;
// this should just be a call to "saverClass.sync(props.saveSource)".
// Same goes with other functions which handle data.
props.setData(newData)
})();
}}
>Sync : null;
return <>
{
props.saveSource.save(props.data)
}}
>Save
{SyncButton}
{
(async () => {
const loadedData = await props.saveSource.load();
props.setData(loadedData)
})();
}}
>Load
props.removeSaveSource()}
>Remove this source
}
export default FileNavbarAndDialog;
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。