aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/CommandsPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/settings/CommandsPage.js')
-rw-r--r--modern/src/settings/CommandsPage.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/modern/src/settings/CommandsPage.js b/modern/src/settings/CommandsPage.js
index 5ff194d5..3963952b 100644
--- a/modern/src/settings/CommandsPage.js
+++ b/modern/src/settings/CommandsPage.js
@@ -11,6 +11,7 @@ import PageLayout from '../common/components/PageLayout';
import SettingsMenu from './components/SettingsMenu';
import CollectionFab from './components/CollectionFab';
import CollectionActions from './components/CollectionActions';
+import TableShimmer from '../common/components/TableShimmer';
const useStyles = makeStyles((theme) => ({
columnAction: {
@@ -25,13 +26,19 @@ const CommandsPage = () => {
const [timestamp, setTimestamp] = useState(Date.now());
const [items, setItems] = useState([]);
+ const [loading, setLoading] = useState(false);
useEffectAsync(async () => {
- const response = await fetch('/api/commands');
- if (response.ok) {
- setItems(await response.json());
- } else {
- throw Error(await response.text());
+ setLoading(true);
+ try {
+ const response = await fetch('/api/commands');
+ if (response.ok) {
+ setItems(await response.json());
+ } else {
+ throw Error(await response.text());
+ }
+ } finally {
+ setLoading(false);
}
}, [timestamp]);
@@ -47,7 +54,7 @@ const CommandsPage = () => {
</TableRow>
</TableHead>
<TableBody>
- {items.map((item) => (
+ {!loading ? items.map((item) => (
<TableRow key={item.id}>
<TableCell>{item.description}</TableCell>
<TableCell>{t(prefixString('command', item.type))}</TableCell>
@@ -56,7 +63,7 @@ const CommandsPage = () => {
<CollectionActions itemId={item.id} editPath="/settings/command" endpoint="commands" setTimestamp={setTimestamp} />
</TableCell>
</TableRow>
- ))}
+ )) : (<TableShimmer columns={4} />)}
</TableBody>
</Table>
<CollectionFab editPath="/settings/command" />