From 6ec70731513794b400d77e3d58e3097d504f2904 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 1 Nov 2023 10:00:05 +0800 Subject: [PATCH] Fix bypass shortcuts limit --- src/components/shortcuts-settings.jsx | 2 +- src/pages/hashtag.jsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx index 2a1ee799..1d551c6c 100644 --- a/src/components/shortcuts-settings.jsx +++ b/src/components/shortcuts-settings.jsx @@ -22,7 +22,7 @@ import Icon from './icon'; import MenuConfirm from './menu-confirm'; import Modal from './modal'; -const SHORTCUTS_LIMIT = 9; +export const SHORTCUTS_LIMIT = 9; const TYPES = [ 'following', diff --git a/src/pages/hashtag.jsx b/src/pages/hashtag.jsx index b17a0b0b..1a7fd0cb 100644 --- a/src/pages/hashtag.jsx +++ b/src/pages/hashtag.jsx @@ -11,6 +11,7 @@ import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; import Icon from '../components/icon'; import Menu2 from '../components/menu2'; import MenuConfirm from '../components/menu-confirm'; +import { SHORTCUTS_LIMIT } from '../components/shortcuts-settings'; import Timeline from '../components/timeline'; import { api } from '../utils/api'; import showToast from '../utils/show-toast'; @@ -313,6 +314,12 @@ function Hashtags({ media: mediaView, columnMode, ...props }) { { + if (states.shortcuts.length >= SHORTCUTS_LIMIT) { + alert( + `Max ${SHORTCUTS_LIMIT} shortcuts reached. Unable to add shortcut.`, + ); + return; + } const shortcut = { type: 'hashtag', hashtag: hashtags.join(' '),