From 650af38a2895cfcd1f706db7a3e105216a356a60 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 14 Apr 2023 11:13:14 +0800 Subject: [PATCH] Make instances optional --- src/components/shortcuts-settings.jsx | 6 ++++-- src/components/shortcuts.jsx | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/shortcuts-settings.jsx b/src/components/shortcuts-settings.jsx index f20d56e6..9960c13c 100644 --- a/src/components/shortcuts-settings.jsx +++ b/src/components/shortcuts-settings.jsx @@ -60,7 +60,8 @@ const TYPE_PARAMS = { text: 'Instance', name: 'instance', type: 'text', - placeholder: 'e.g. mastodon.social', + placeholder: 'Optional, e.g. mastodon.social', + notRequired: true, }, ], trending: [ @@ -68,7 +69,8 @@ const TYPE_PARAMS = { text: 'Instance', name: 'instance', type: 'text', - placeholder: 'e.g. mastodon.social', + placeholder: 'Optional, e.g. mastodon.social', + notRequired: true, }, ], search: [ diff --git a/src/components/shortcuts.jsx b/src/components/shortcuts.jsx index 8ab5ed91..30d429bc 100644 --- a/src/components/shortcuts.jsx +++ b/src/components/shortcuts.jsx @@ -7,6 +7,7 @@ import { useNavigate } from 'react-router-dom'; import { useSnapshot } from 'valtio'; import { SHORTCUTS_META } from '../components/shortcuts-settings'; +import { api } from '../utils/api'; import states from '../utils/states'; import AsyncText from './AsyncText'; @@ -15,6 +16,7 @@ import Link from './link'; import MenuLink from './menu-link'; function Shortcuts() { + const { instance } = api(); const snapStates = useSnapshot(states); const { shortcuts } = snapStates; @@ -36,7 +38,13 @@ function Shortcuts() { id = id(data, i); } if (typeof path === 'function') { - path = path(data, i); + path = path( + { + ...data, + instance: data.instance || instance, + }, + i, + ); } if (typeof title === 'function') { title = title(data, i);