From 45a1fc057edb59b150c51b0f7c3eeaaa0f901785 Mon Sep 17 00:00:00 2001
From: Lim Chee Aun
Date: Sat, 18 Feb 2023 19:39:17 +0800
Subject: [PATCH] Limit number of shortcuts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
9 because there's only 9 keyboard shortcuts. There's '0' but… nah.
---
src/components/shortcuts-settings.jsx | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx
index b21ff898..b793d47c 100644
--- a/src/components/shortcuts-settings.jsx
+++ b/src/components/shortcuts-settings.jsx
@@ -9,6 +9,8 @@ import states from '../utils/states';
import AsyncText from './AsyncText';
import Icon from './icon';
+const SHORTCUTS_LIMIT = 9;
+
const TYPES = [
'following',
'notifications',
@@ -134,6 +136,7 @@ export const SHORTCUTS_META = {
function ShortcutsSettings() {
const snapStates = useSnapshot(states);
const { masto } = api();
+ const { shortcuts } = snapStates;
const [lists, setLists] = useState([]);
const [followedHashtags, setFollowedHashtags] = useState([]);
@@ -187,7 +190,7 @@ function ShortcutsSettings() {
{snapStates.shortcuts.length > 0 ? (
- {snapStates.shortcuts.map((shortcut, i) => {
+ {shortcuts.map((shortcut, i) => {
const key = i + Object.values(shortcut);
const { type } = shortcut;
let { icon, title } = SHORTCUTS_META[type];
@@ -223,7 +226,7 @@ function ShortcutsSettings() {