Fix bypass shortcuts limit

This commit is contained in:
Lim Chee Aun 2023-11-01 10:00:05 +08:00
parent 22abc2fb31
commit 6ec7073151
2 changed files with 8 additions and 1 deletions

View file

@ -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',

View file

@ -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 }) {
<MenuItem
disabled={!currentAuthenticated}
onClick={() => {
if (states.shortcuts.length >= SHORTCUTS_LIMIT) {
alert(
`Max ${SHORTCUTS_LIMIT} shortcuts reached. Unable to add shortcut.`,
);
return;
}
const shortcut = {
type: 'hashtag',
hashtag: hashtags.join(' '),